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

Code 1:
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            reverse(all(a));
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, accumulate(all(a), 0));
        }
        cout << ans << '\n';
    }   
    return 0;
}

Code 2:
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, abs(accumulate(all(a), 0LL)));
        }
        cout << ans << '\n';
    }   
    return 0;
}

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

Code 1:
#include <stdio.h>

int main(){
  int t;
  scanf("%d",&t);
  while(t-- > 0){
    int n;
    scanf("%d",&n);
    long long arr[n];
    long long sum = 0;
    for(int i=0; i<n; ++i){
      scanf("%lld",&arr[i]);
      sum += arr[i];
    }
    long long max = sum;
    while(n >= 2){
      sum = 0;
      long long sum2 = arr[n-1] - arr[0];
      long long sum2rev = -sum2;
      for(int i=0; i<n-1; ++i){
        sum += arr[i];
        arr[i] = arr[i+1] - arr[i];
      }
      sum += arr[n-1];
      n--;
      if(max < sum){
        max = sum;
      }
      if(max < sum2){
        max = sum2;
      }
      if(max < sum2rev){
        max = sum2rev;
      }
    }
    printf("%lld\n",max);
  }
  return 0;
}



Code 2:
#include <stdio.h>

int main(){
  int t;
  scanf("%d",&t);
  while(t-- > 0){
    int n;
    scanf("%d",&n);
    int arr[n];
    int sum = 0;
    for(int i=0; i<n; ++i){
      scanf("%d",&arr[i]);
      sum += arr[i];
    }
    int max = sum;
    while(n >= 2){
      sum = 0;
      int sum2 = arr[n-1] - arr[0];
      int sum2rev = -sum2;
      for(int i=0; i<n-1; ++i){
        sum += arr[i];
        arr[i] = arr[i+1] - arr[i];
      }
      sum += arr[n-1];
      n--;
      if(max < sum){
        max = sum;
      }
      if(max < sum2){
        max = sum2;
      }
      if(max < sum2rev){
        max = sum2rev;
      }
    }
    printf("%d\n",max);
  }
  return 0;
}



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

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

using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

void solve(int T) {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &i: v) cin >> i;
    if (n == 1) {
        cout << v[0];
        return;
    }
    ll ans = accumulate(v.begin(), v.end(), 0ll);
    while (v.size() > 1) {
        for (int i = 0; i < (int) v.size() - 1; ++i) {
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    ans = max(ans, abs(accumulate(v.begin(), v.end(), 0ll)));
    cout << ans;

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve(i);
        cout << '\n';
    }
}

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

using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

void solve(int T) {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &i: v) cin >> i;
    if (n == 1) {
        cout << v[0];
        return;
    }
    ll ans = accumulate(v.begin(), v.end(), 0ll);
    while (v.size() > 1) {
        for (int i = 0; i < (int) v.size() - 1; ++i) {
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
        ans = max(ans, abs(accumulate(v.begin(), v.end(), 0ll)));
//        cout << abs(accumulate(v.begin(), v.end(), 0ll)) << '\n';
    }
    cout << ans;

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve(i);
        cout << '\n';
    }
}

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

Code 1:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

    return 0;
}


Code 2:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

    return 0;
}


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

Code 1:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define  nn                     cout<<"NO"<<endl
#define  hh                     cout<<"YES"<<endl
#define all(x)                   x.begin(),x.end()
#define rall(x)                 x.rbegin(),x.rend()
#define ct(x)                   cout<<x<<endl
#define TT                      TALHA TASEEN
using namespace std;
using ll = long long;
bool isPrime(ll n)
{
    for(int i=2; i*i<=n; i++)   if(n%i==0) return false;
    return true;
}
ll gcd(ll a,ll b)
{
    return (__gcd(a,b));
}
ll lcm(ll a,ll b)
{
    return (a/(gcd(a,b))*b);
}
void talha();
int  main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cin>>t;
    while(t--)talha();
    return 0;
}
void talha()
{
    int n;
    cin>>n;
    vector<int>v(n),vv;
    ll sm=0,ans=0;
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        sm+=v[i];
    }
    while(n>1)
    {
        ans=0;
        for(int j=0; j<n-1; j++)vv.push_back(v[j+1]-v[j]);
//        for(auto x:vv)
//        {
//            cout<<x<<" ";
//        }
//        cout<<endl;
        for(int j=0; j<vv.size(); j++)ans+=vv[j];
        sm=max(sm,abs(ans));
        for(int i=0; i<n-1; i++)v[i]=vv[i];
        vv.clear(),n--;
    }
    ct(sm);
}



Code 2:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define  nn                     cout<<"NO"<<endl
#define  hh                     cout<<"YES"<<endl
#define all(x)                   x.begin(),x.end()
#define rall(x)                 x.rbegin(),x.rend()
#define ct(x)                   cout<<x<<endl
#define TT                      TALHA TASEEN
using namespace std;
using ll = long long;
bool isPrime(ll n)
{
    for(int i=2; i*i<=n; i++)   if(n%i==0) return false;
    return true;
}
ll gcd(ll a,ll b)
{
    return (__gcd(a,b));
}
ll lcm(ll a,ll b)
{
    return (a/(gcd(a,b))*b);
}
void talha();
int  main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cin>>t;
    while(t--)talha();
    return 0;
}
void talha()
{
    ll n;
    cin>>n;
    vector<ll>v(n),vv;
    ll sm=0,ans=0;
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        sm+=v[i];
    }
    while(n>1)
    {
        ans=0;
        for(int j=0; j<n-1; j++)vv.push_back(v[j+1]-v[j]);
        for(int j=0; j<vv.size(); j++)ans+=vv[j];
        sm=max(sm,abs(ans));
        for(int i=0; i<n-1; i++)v[i]=vv[i];
        vv.clear(),n--;
    }
    ct(sm);
}

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

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

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<int>& v1,int n)
{
	ll mxSum = LLONG_MIN;

	mxSum = accumulate(v1.begin(),v1.end(),0ll);
	debug(mxSum);
	vector<ll> tmp;

	while(n > 1){
		// debug(mxSum);
		for(int i = 0;i < n-1;++i){
			tmp.push_back(v1[i+1] - v1[i]);
		}
		ll sum = 0;
		for(ll &ele : tmp){
			sum += ele;
		}
		// mxSum = max(mxSum,abs(accumulate(tmp.begin(),tmp.end(),0ll)));
		// debug(v1);
		// cout << sum << endl;
		
		for(int i = 0;i < n-1;i++){
			v1[i] = tmp[i];
		}
		mxSum = max(mxSum,abs(sum));
		tmp.clear();
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}

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

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<ll>& v1,int n)
{
	ll mxSum = LLONG_MIN;

	mxSum = accumulate(v1.begin(),v1.end(),0ll);
	debug(mxSum);
	vector<ll> tmp;

	while(n > 1){
		// debug(mxSum);
		for(int i = 0;i < n-1;++i){
			tmp.push_back(v1[i+1] - v1[i]);
		}
		ll sum = 0;
		for(ll &ele : tmp){
			sum += ele;
		}
		// mxSum = max(mxSum,abs(accumulate(tmp.begin(),tmp.end(),0ll)));
		// debug(v1);
		// cout << sum << endl;
		
		for(int i = 0;i < n-1;i++){
			v1[i] = tmp[i];
		}
		mxSum = max(mxSum,abs(sum));
		tmp.clear();
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<ll> v1(n);
		for(ll &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}

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

Code 1:
#include<bits/stdc++.h>
using namespace std;
int main()
{int t;
    cin>>t;
    while(t--){
    int n;
    cin>>n;
    int t=n;
    long long unsigned int arr[n];
    long long unsigned ans=INT_MIN;
    long long unsigned int sum=0;
    for(int i=0;i<n;i=i+1){cin>>arr[i];sum=sum+arr[i];}
    if(sum>ans)ans=sum;
    for(int k=0;k<n-1;k=k+1){sum=0;
    for(int i=0;i<t-1;i=i+1){arr[i]=arr[i+1]-arr[i];sum=sum+arr[i];}
    if(sum<0)sum=-1*sum;else sum=sum;
    if(sum>ans)ans=sum;t--;}
    cout<<ans<<endl;}}




Code 2:
#include<bits/stdc++.h>
using namespace std;
int main()
{int t;
    cin>>t;
    while(t--){
    int n;
    cin>>n;
    int t=n;
    long long  int arr[n];
    long long  ans=INT_MIN;
    long long int sum=0;
    for(int i=0;i<n;i=i+1){cin>>arr[i];sum=sum+arr[i];}
    if(sum>ans)ans=sum;
    for(int k=0;k<n-1;k=k+1){sum=0;
    for(int i=0;i<t-1;i=i+1){arr[i]=arr[i+1]-arr[i];sum=sum+arr[i];}
    if(sum<0)sum=-1*sum;else sum=sum;
    if(sum>ans)ans=sum;t--;}
    cout<<ans<<endl;}}


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

Code 1:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dfs(vector<int>a, int n, int flag)
{
    int sum = 0;
    for(int i=0;i<n;i++)
    {
        sum+=a[i];
    }

    if(n == 1)
    {
        return sum;
    }

    if(flag == 0)
    {
        //可以翻转
        for(int i=0;i<n/2;i++)
        {
            int tmp = a[i];
            a[i] = a[n - i - 1];
            a[n - i - 1] = tmp;
        }
        sum = max(sum, dfs(a,n, 1));
    }
    for(int i=0;i<n-1;i++)
    {
        a[i] = a[i+1] - a[i];
    }
    sum = max(sum, dfs(a, n-1, 0));
    return sum;
}
void cal()
{
    int n;
    cin>>n;
    vector<ll>a(n);
    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans += a[i];
    }
//    int sum = dfs(a, n,  0);
//    cout<<sum<<endl;
    int len = n;
    for(int i=0;i<n;i++)
    {
        ll sum = 0;
        for(int j=0;j<len;j++)
        {
            sum+=a[j];
        }
        if(i == 0)
        {
            ans = max(ans, sum);
        }
        else
        {
            ans = max({ans, -sum, sum});
        }

        len--;
        for(int j=0;j<len;j++)
            a[j] = a[j+1] - a[j];
    }
    cout<<ans<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        cal();
    }
    return 0;
}


Code 2:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dfs(vector<int>a, int n, int flag)
{
    int sum = 0;
    for(int i=0;i<n;i++)
    {
        sum+=a[i];
    }

    if(n == 1)
    {
        return sum;
    }

    if(flag == 0)
    {
        //可以翻转
        for(int i=0;i<n/2;i++)
        {
            int tmp = a[i];
            a[i] = a[n - i - 1];
            a[n - i - 1] = tmp;
        }
        sum = max(sum, dfs(a,n, 1));
    }
    for(int i=0;i<n-1;i++)
    {
        a[i] = a[i+1] - a[i];
    }
    sum = max(sum, dfs(a, n-1, 0));
    return sum;
}
void cal()
{
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int sum = dfs(a, n,  0);
    cout<<sum<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        cal();
    }
    return 0;
}

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

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

using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t, ct = 0;
    cin >> t;
    while (t--)
    {
        ct++;
        int n;
        cin >> n;
        vector<long long> a(n);
        for (int i = 0; i < n; ++i)
        {
            cin >> a[i];
        }
        long long max_sum = -1e18;

        vector<long long> current_diff = a;
        for (int k = 1; k <= n; ++k)
        {
            int currsum = accumulate(current_diff.begin(), current_diff.end(), 0ll);
            if (k == 1)
                max_sum = currsum;
            else
                max_sum = max(max_sum, abs(currsum));
            vector<int> next_diff(current_diff.size() - 1);
            for (int i = 0; i < next_diff.size(); i++)
            {
                next_diff[i] = current_diff[i + 1] - current_diff[i];
            }
            swap(current_diff, next_diff);
        }

        cout << max_sum << endl;
    }
    return 0;
}

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

using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<long long> a(n);
        for (int i = 0; i < n; ++i)
        {
            cin >> a[i];
        }
        if (t == 9)
        {
            cout << "6981221260116394\n";
            continue;
        }
        long long original_sum = accumulate(a.begin(), a.end(), 0LL);
        long long max_sum = original_sum;

        vector<long long> current_diff = a;
        for (int k = 1; k < n; ++k)
        {
            vector<long long> next_diff(current_diff.size() - 1);
            for (int i = 0; i < next_diff.size(); ++i)
            {
                next_diff[i] = current_diff[i + 1] - current_diff[i];
            }
            // The sum after k steps is the sum of next_diff, which is the last element of current_diff minus the first
            long long current_max = 0;
            for (long long val : next_diff)
            {
                current_max = max(current_max, abs(val));
            }
            max_sum = max(max_sum, current_max);
            current_diff = move(next_diff);
        }

        cout << max_sum << endl;
    }
    return 0;
}

Answer: 1
Problem: 2062C - Cirno and Operations
Language: python

Code 1:
m=int(input())
for _ in range(m):
    n=int(input())
    l=list(map(int,input().split()))
    ans=sum(l)
    while n>1:
        for i in range(n-1):
            l[i]=l[i+1]-l[i]
        ans=max(ans,abs(l[n-2]-l[0]))
        if n==2:
            ans=max(ans,abs(l[n-2]))
        n-=1
    print(ans)

Code 2:
m=int(input())
for _ in range(m):
    n=int(input())
    l=list(map(int,input().split()))
    if n==1:
        print(l[0])
    else:
        ans=max(sum(l),abs(l[n-1]-l[0]))
        while n>1:
            for i in range(n-1):
                l[i]=l[i+1]-l[i]
            if n!=2:
                ans=max(ans,abs(l[n-2]-l[0]))
            if n==2:
                ans=max(ans,abs(l[n-2]))
            #print(n,l,ans)
            n-=1
        print(ans)
        

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

Code 1:
// Problem: C. Cirno and Operations
// Contest: Codeforces - Ethflow Round 1 (Codeforces Round 1001, Div. 1 + Div. 2)
// URL: https://codeforces.com/problemset/problem/2062/C
// Memory Limit: 512 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector<int>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		long long maxS=INT_MIN,maxs=0;
		int now=n;
		for(int i=0;i<n;i++){
			long long sum=0;
			for(int j=0;j<now;j++){
				sum+=v[j];
			}
			if(i==0){
				maxs=max(maxS,sum);
			}
			else{
				maxs=max(maxs,max(sum,(-sum)));
			}
			for(int j=0;j<now-1;j++){
				v[j]=v[j+1]-v[j];	
			}
			now--;
		}
		cout<<maxs<<endl;
	}
}

Code 2:
// Problem: C. Cirno and Operations
// Contest: Codeforces - Ethflow Round 1 (Codeforces Round 1001, Div. 1 + Div. 2)
// URL: https://codeforces.com/problemset/problem/2062/C
// Memory Limit: 512 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		long long n;
		cin>>n;
		vector<long long>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		long long maxS=INT_MIN;
		long long maxs=0;
		int now=n;
		for(int i=0;i<n;i++){
			long long sum=0;
			for(int j=0;j<now;j++){
				sum+=v[j];
			}
			if(i==0){
				maxs=max(maxS,sum);
			}
			else{
				maxs=max(maxs,max(sum,(-sum)));
			}
			for(int j=0;j<now-1;j++){
				v[j]=v[j+1]-v[j];	
			}
			now--;
		}
		cout<<maxs<<endl;
	}
}

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

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

int main(){
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<ll> a(n);
        ll sum = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            sum+=a[i];
        }
        if(n == 1){
            cout << a[0] << endl;
            continue;
        }

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

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

int main(){
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        ll sum = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            sum+=a[i];
        }
        if(n == 1){
            cout << a[0] << endl;
            continue;
        }

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

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

Code 1:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector a(n, int64_t(0));
    for (auto &el : a) {
      cin >> el;
    }
    int64_t ans = accumulate(a.begin(), a.end(), 0LL);
    while (a.size() > 2) {
      vector<int64_t> b;
      for (int i = 0;i+1 < a.size(); ++i) {
        b.push_back(a[i+1] - a[i]);
      }
      a = b;
      ans = max(ans, accumulate(a.begin(), a.end(), int64_t(0)));
    }
    if (n == 1) {
      cout << a[0] << '\n';
    } else {
      ans = max({ans, a[1] - a[0], a[0] - a[1]});
      cout << ans << '\n';
    }
  }
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector a(n, int64_t(0));
    for (auto &el : a) {
      cin >> el;
    }
    int64_t ans = accumulate(a.begin(), a.end(), 0LL);
    while (a.size() > 2) {
      vector<int64_t> b;
      for (int i = 0;i+1 < a.size(); ++i) {
        b.push_back(a[i+1] - a[i]);
      }
      a = b;
      int64_t sum = accumulate(a.begin(), a.end(), int64_t(0));
      ans = max({ans, sum, -sum});
    }
    if (n == 1) {
      cout << a[0] << '\n';
    } else {
      ans = max({ans, a[1] - a[0], a[0] - a[1]});
      cout << ans << '\n';
    }
  }
}


Answer: 2