ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long

using namespace std;

void solve(){
    int n; cin >> n;
    vector<int> a(n);
    for(auto &e:a) cin >> e;
    if(n==1){
        cout << a[0] << "\n";
        return;
    }
    int ans = accumulate(a.begin(), a.end(), 0);
    for(int c=0;c<n && (int)a.size()>1;c++){
        vector<int> nv;
        int ns = 0;
        for(int i=(int)a.size()-1;i;--i){
            nv.emplace_back(a[i-1]-a[i]);
            ns += a[i-1]-a[i];
        }
        swap(nv, a);
        ans = max(ans, ns);
    }
    cout << ans << "\n";
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int tc; cin >> tc;
    while(tc--) solve();

    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long

using namespace std;

void solve(){
    int n; cin >> n;
    vector<ll> a(n);
    for(auto &e:a) cin >> e;
    if(n==1){
        cout << a[0] << "\n";
        return;
    }
    ll ans = accumulate(a.begin(), a.end(), 0);
    for(int c=0;c<n && (int)a.size()>1;c++){
        vector<ll> nv;
        ll ns = 0;
        for(int i=(int)a.size()-1;i;--i){
            nv.emplace_back(a[i-1]-a[i]);
            ns += a[i-1]-a[i];
        }
        swap(nv, a);
        ans = max(ans, ns);
    }
    cout << ans << "\n";
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int tc; cin >> tc;
    while(tc--) solve();

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long

using namespace std;

void solve(){
    int n; cin >> n;
    vector<int> a(n);
    for(auto &e:a) cin >> e;
    if(n==1){
        cout << a[0] << "\n";
        return;
    }
    int ans = accumulate(a.begin(), a.end(), 0);
    for(int c=0;c<n && (int)a.size()>1;c++){
        vector<int> nv;
        int ns = 0;
        for(int i=(int)a.size()-1;i;--i){
            nv.emplace_back(a[i-1]-a[i]);
            ns += a[i-1]-a[i];
        }
        swap(nv, a);
        ans = max(ans, ns);
    }
    cout << ans << "\n";
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int tc; cin >> tc;
    while(tc--) solve();

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;
#define ll long long
void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    for(ll &i: a) cin>>i;
    ll best = -1e18;
    int now = n;
    for(int i = 1; i<=n; i++){
        ll sum = 0;
        for(int i = 0; i<now; i++) sum+=a[i];
        if(n == 1) best = max(best, sum);
        else best = max(best, max(sum, -sum));
        for(int i = 0; i<now-1; i++) a[i] = a[i+1] - a[i];
        now--;
    }
    cout<<best<<'\n';
}

/*
1
9
9 7 9 -9 9 -8 7 -8 9

*/

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


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>

using namespace std;
#define ll long long
void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    for(ll &i: a) cin>>i;
    ll best = -1e18;
    int now = n;
    for(int i = 1; i<=n; i++){
        ll sum = 0;
        for(int i = 0; i<now; i++) sum+=a[i];
        if(now == 1) best = max(best, sum);
        else best = max(best, max(sum, -sum));
        for(int i = 0; i<now-1; i++) a[i] = a[i+1] - a[i];
        now--;
    }
    cout<<best<<'\n';
}

/*
1
9
9 7 9 -9 9 -8 7 -8 9

*/

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t;
    cin>>t;
    while(t--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>

using namespace std;
#define ll long long
void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    for(ll &i: a) cin>>i;
    ll best = -1e18;
    int now = n;
    for(int i = 1; i<=n; i++){
        ll sum = 0;
        for(int i = 0; i<now; i++) sum+=a[i];
        if(now == 1) best = max(best, sum);
        else best = max(best, max(sum, -sum));
        for(int i = 0; i<now-1; i++) a[i] = a[i+1] - a[i];
        now--;
    }
    cout<<best<<'\n';
}

/*
1
9
9 7 9 -9 9 -8 7 -8 9

*/

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


Submission (verdict: Accepted):
#include<bits/stdc++.h>

using namespace std;
#define ll long long
ll a[1010];
void solve(){
    int n;
    cin>>n;
    for(int i = 1; i<=n; i++) cin>>a[i];
    int now = n;
    long long ans = -1e18;

    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, max(sum, -sum));

        for(int i = 1; i<now; i++){
            a[i] = a[i+1] - a[i];
        }
        now--;
    }
    cout<<ans<<'\n';
}

/*
1
2
-1 -1

*/

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t;
    cin>>t;
    while(t--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;
#define ll long long
void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    for(ll &i: a) cin>>i;
    ll best = -1e18;
    int now = n;
    for(int i = 1; i<=n; i++){
        ll sum = 0;
        for(int i = 0; i<now; i++) sum+=a[i];
        if(n == 1) best = max(best, sum);
        else best = max(best, max(sum, -sum));
        for(int i = 0; i<now-1; i++) a[i] = a[i+1] - a[i];
        now--;
    }
    cout<<best<<'\n';
}

/*
1
9
9 7 9 -9 9 -8 7 -8 9

*/

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t;
    cin>>t;
    while(t--) solve();
}
Problem: 2060D - Subtract Min Sort
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
for i in range(int(input())):
    n = int(input())
    array = list(map(int, input().split()))
    ans = "YES"
    # 1 3 2
    for i in range(n - 1):
        mn = min(array[i], array[i + 1])
        array[i] -= mn
        array[i + 1] -= mn
    for i in range(1, n, 2):
        if array[i] < array[i - 1]:
            ans = "NO"
            break
    print(ans)

Submission (verdict: Accepted):
for i in range(int(input())):
    n = int(input())
    array = list(map(int, input().split()))
    ans = "YES"
    # 1 3 2
    for i in range(n - 1):
        mn = min(array[i], array[i + 1])
        array[i] -= mn
        array[i + 1] -= mn
    for i in range(1, n):
        if array[i] < array[i - 1]:
            ans = "NO"
            break
    print(ans)
Problem: 2060D - Subtract Min Sort
Language: Python 3


Submission (verdict: Wrong answer on test 2):
for i in range(int(input())):
    n = int(input())
    array = list(map(int, input().split()))
    # 1 2 3 4 5 6 7
    ans = "YES"
    if n % 2 == 0:
        if n == 2:
            if not (array[n - 1] >= array[n - 2]):
                ans = "NO"
        else:
            for i in range(1, n, 2):
                if i == n - 1:
                    if not (array[i] >= array[i - 1]):
                        ans = "NO"
                elif not (array[i] >= array[i - 1] and array[i + 1] >= array[i] - array[i - 1]):
                    ans = "NO"
                    break            
    else:
        if n == 3:
            if not (array[n - 1] >= array[n - 2] and array[n - 2] >= array[n - 3]):
                ans = "NO"
        else:
            for i in range(1, n - 3, 2):
                if i == n - 1:
                    if not (array[i] >= array[i - 1]):
                        ans = "NO"
                elif not (array[i] >= array[i - 1] and array[i + 1] >= array[i] - array[i - 1]):
                    ans = "NO"
                    break
            if array[n - 1] >= array[n - 2] and array[n - 2] >= array[n - 3]:
                if not (array[n - 3] >= array[n - 4] - array[n - 5]):
                    ans = "NO"
            else:
                ans = "NO"
    print(ans)
Problem: 2060D - Subtract Min Sort
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
for i in range(int(input())):
    n = int(input())
    array = list(map(int, input().split()))
    ans = "YES"
    # 1 3 2
    for i in range(1, n, 2):
        if n % 2 == 0 and i == n - 1:
            if not (array[i] >= array[i - 1]):
                ans = "NO"
        elif not (array[i] >= array[i - 1] and array[i + 1] >= array[i] - array[i - 1]):
            ans = "NO"
            break
    if n % 2 != 0:
        if not (array[n - 1] >= array[n - 2] - array[n - 3]):
            ans = "NO"
    print(ans)

Submission (verdict: Wrong answer on test 2):
for i in range(int(input())):
    n = int(input())
    array = list(map(int, input().split()))
    ans = "YES"
    # 1 3 2
    for i in range(n - 1):
        mn = min(array[i], array[i + 1])
        array[i] -= mn
        array[i + 1] -= mn
    for i in range(1, n, 2):
        if array[i] < array[i - 1]:
            ans = "NO"
            break
    print(ans)
Problem: 2060D - Subtract Min Sort
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
for i in range(int(input())):
    n = int(input())
    array = list(map(int, input().split()))
    # 1 2 3 4 5 6 7
    ans = "YES"
    if n % 2 == 0:
        if n == 2:
            if not (array[n - 1] >= array[n - 2]):
                ans = "NO"
        else:
            for i in range(1, n, 2):
                if i == n - 1:
                    if not (array[i] >= array[i - 1]):
                        ans = "NO"
                elif not (array[i] >= array[i - 1] and array[i + 1] >= array[i] - array[i - 1]):
                    ans = "NO"
                    break            
    else:
        if n == 3:
            if not (array[n - 1] >= array[n - 2] and array[n - 2] >= array[n - 3]):
                ans = "NO"
        else:
            for i in range(1, n - 3, 2):
                if i == n - 1:
                    if not (array[i] >= array[i - 1]):
                        ans = "NO"
                elif not (array[i] >= array[i - 1] and array[i + 1] >= array[i] - array[i - 1]):
                    ans = "NO"
                    break
            if array[n - 1] >= array[n - 2] and array[n - 2] >= array[n - 3]:
                if not (array[n - 3] >= array[n - 4] - array[n - 5]):
                    ans = "NO"
            else:
                ans = "NO"
    print(ans)




Submission (verdict: Wrong answer on test 2):
for i in range(int(input())):
    n = int(input())
    array = list(map(int, input().split()))
    ans = "YES"
    # 1 3 2
    for i in range(1, n, 2):
        if n % 2 == 0 and i == n - 1:
            if not (array[i] >= array[i - 1]):
                ans = "NO"
        elif not (array[i] >= array[i - 1] and array[i + 1] >= array[i] - array[i - 1]):
            ans = "NO"
            break
    if n % 2 != 0:
        if not (array[n - 1] >= array[n - 2] - array[n - 3]):
            ans = "NO"
    print(ans)
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    long long t ;

    cin >> t ;

    while(t--){

        long long x ;

        cin >> x ;

        long long ans = x ;

        long long two = 0 , thr = 0 , sum = 0 ;

        while(x > 0){

            sum = sum + x % 10 ;

            if(x % 10 == 2)
                two++;

            if(x % 10 == 3)
                thr++;

            x /= 10 ;

        }

        bool f = 0 ;

        for(long long i = 0 ; i <= two ; i++)
            for(long long j = 0 ; j <= thr ; j++)
        if((sum + (i * 2) + (j * 6)) % 9 == 0)
            f = 1 ;

        if(f)
            cout << "YES\n";

        else
            cout << "NO\n";

    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    long long t ;

    cin >> t ;

    while(t--){

        long long x ;

        cin >> x ;

        long long ans = x ;

        long long two = 0 , thr = 0 , sum = 0 ;

        while(x > 0){

            sum = sum + x % 10 ;

            if(x % 10 == 2)
                two++;

            if(x % 10 == 3)
                thr++;

            x /= 10 ;

        }

        bool f = 0 ;

        for(long long i = 0 ; i <= two ; i++)
            for(long long j = 0 ; j <= thr ; j++)
        if((sum + (i * 2) + (j * 6)) % 9 == 0)
            f = 1 ;

        if(f)
            cout << "YES\n";

        else
            cout << "NO\n";

    }

    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    long long t ;

    cin >> t ;

    while(t--){

        long long x ;

        cin >> x ;

        long long ans = x ;

        long long two = 0 , thr = 0 , sum = 0 ;

        while(x > 0){

            sum = sum + x % 10 ;

            if(x % 10 == 2)
                two++;

            if(x % 10 == 3)
                thr++;

            x /= 10 ;

        }

        bool f = 0 ;

        if(two > 8)
            two = 8 ;

        if(thr > 8)
            thr = 8 ;

        for(long long i = 0 ; i <= two ; i++)
            for(long long j = 0 ; j <= thr ; j++)
        if((sum + (i * 2) + (j * 6)) % 9 == 0)
            f = 1 ;

        if(f)
            cout << "YES\n";

        else
            cout << "NO\n";

    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    long long t ;

    cin >> t ;

    while(t--){

        long long x ;

        cin >> x ;

        long long ans = x ;

        long long two = 0 , thr = 0 , sum = 0 ;

        while(x > 0){

            sum = sum + x % 10 ;

            if(x % 10 == 2)
                two++;

            if(x % 10 == 3)
                thr++;

            x /= 10 ;

        }

        bool f = 0 ;

        if(two > 8)
            two = 8 ;

        if(thr > 8)
            thr = 8 ;

        for(long long i = 0 ; i <= two ; i++)
            for(long long j = 0 ; j <= thr ; j++)
        if((sum + (i * 2) + (j * 6)) % 9 == 0)
            f = 1 ;

        if(f)
            cout << "YES\n";

        else
            cout << "NO\n";

    }

    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    long long t ;

    cin >> t ;

    while(t--){

        string x ;

        cin >> x ;

        long long two = 0 , thr = 0 , sum = 0 ;

        for(long long i = 0 ; i < x.length() ; i++){

            if(x[i] == '2')
                two++;

            if(x[i] == '3')
                thr++;

            sum += x[i] - '0';

        }


        bool f = 0 ;

        if(two > 8)
            two = 8 ;

        if(thr > 8)
            thr = 8 ;

        for(long long i = 0 ; i <= two ; i++)
            for(long long j = 0 ; j <= thr ; j++)
        if((sum + (i * 2) + (j * 6)) % 9 == 0)
            f = 1 ;

        if(f)
            cout << "YES\n";

        else
            cout << "NO\n";

    }

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
int32_t main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  while (T--)
  {
    int n;
    cin >> n;
    map<pair<int, int>, int> m;
    vector<int> v(n, 0);
    vector<pair<int, int>> vv;
    for (int i = 0; i < n - 1; i++)
    {
      int a, b;
      cin >> a >> b;
      a--, b--;
      v[a]++;
      v[b]++;
      m[{a, b}] = 1;
      m[{b, a}] = 1;
    }
    for (int i = 0; i < n; i++)
    {
      vv.push_back({v[i], i});
    }
    sort(vv.rbegin(), vv.rend());
    int ans = 0;
    for (int i = 0; i < 2; i++)
    {
      for (int j = i + 1; j < n; j++)
      {
        int tmp = v[i] + v[j] - 1;
        if (m.find({i, j}) != m.end())
          tmp--;
        ans = max(ans, tmp);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
int32_t main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  while (T--)
  {
    int n;
    cin >> n;
    map<pair<int, int>, int> m;
    vector<int> v(n, 0);
    vector<pair<int, int>> vv;
    for (int i = 0; i < n - 1; i++)
    {
      int a, b;
      cin >> a >> b;
      a--, b--;
      v[a]++;
      v[b]++;
      m[{a, b}] = 1;
      m[{b, a}] = 1;
    }
    for (int i = 0; i < n; i++)
    {
      vv.push_back({v[i], i});
    }
    sort(vv.rbegin(), vv.rend());
    int ans = 0;
    for (int i = 0; i < 2; i++)
    {
      for (int j = i + 1; j < n; j++)
      {
        int tmp = vv[i].first + vv[j].first - 1;
        if (m.find({vv[i].second, vv[j].second}) != m.end())
          tmp--;
        ans = max(ans, tmp);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
int32_t main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  while (T--)
  {
    int n;
    cin >> n;
    map<pair<int, int>, int> m;
    vector<int> v(n, 0);
    vector<pair<int, int>> vv;
    for (int i = 0; i < n - 1; i++)
    {
      int a, b;
      cin >> a >> b;
      a--, b--;
      v[a]++;
      v[b]++;
      m[{a, b}] = 1;
      m[{b, a}] = 1;
    }
    for (int i = 0; i < n; i++)
    {
      vv.push_back({v[i], i});
    }
    sort(vv.rbegin(), vv.rend());
    int ans = 0;
    for (int i = 0; i < 2; i++)
    {
      for (int j = i + 1; j < n; j++)
      {
        int tmp = v[i] + v[j] - 1;
        if (m[{i, j}] == 1)
          tmp--;
        ans = max(ans, tmp);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
int32_t main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  while (T--)
  {
    int n;
    cin >> n;
    map<pair<int, int>, int> m;
    vector<int> v(n, 0);
    vector<pair<int, int>> vv;
    for (int i = 0; i < n - 1; i++)
    {
      int a, b;
      cin >> a >> b;
      a--, b--;
      v[a]++;
      v[b]++;
      m[{a, b}] = 1;
      m[{b, a}] = 1;
    }
    for (int i = 0; i < n; i++)
    {
      vv.push_back({v[i], i});
    }
    sort(vv.rbegin(), vv.rend());
    int ans = 0;
    for (int i = 0; i < 2; i++)
    {
      for (int j = i + 1; j < n; j++)
      {
        int tmp = v[i] + v[j] - 1;
        if (m.find({i, j}) != m.end())
          tmp--;
        ans = max(ans, tmp);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
int32_t main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  while (T--)
  {
    int n;
    cin >> n;
    map<pair<int, int>, int> m;
    vector<int> v(n, 0);
    vector<pair<int, int>> vv;
    for (int i = 0; i < n - 1; i++)
    {
      int a, b;
      cin >> a >> b;
      a--, b--;
      v[a]++;
      v[b]++;
      m[{a, b}] = 1;
      m[{b, a}] = 1;
    }
    for (int i = 0; i < n; i++)
    {
      vv.push_back({v[i], i});
    }
    sort(vv.rbegin(), vv.rend());
    int ans = 0;
    for (int i = 0; i < 2; i++)
    {
      for (int j = i + 1; j < n; j++)
      {
        int tmp = v[i] + v[j] - 1;
        if (m[{i, j}] == 1)
          tmp--;
        ans = max(ans, tmp);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

vector<int> reverseArray(vector<int> &arr) {
    vector<int> ret;
    int n=arr.size();
    for (int i=n-1;i>=0;i--){
        ret.push_back(arr[i]);
    }
    return ret;
}

vector<long long> diffArray(vector<long long> &arr) {
    vector<long long> ret;
    int n=arr.size();
    for(int i=1;i<n;i++) {
        ret.push_back(arr[i] - arr[i-1]);
    }
    return ret;
}

long long sumOf(vector<long long> &arr) {
    long long ans = 0ll;
    for(int i: arr) {
        ans+=i;
    }
    return ans;
}

void solve(){
    int n;
    cin>>n;
    vector<long long> a(n,0ll);
    for (auto &i:a) {
        cin>>i;
    }
    long long ans = sumOf(a);
    while(n>1) {
        a = diffArray(a);
        ans=max(ans, abs(sumOf(a)));
        n--;
    }
    cout<<max(ans, abs(a[0]))<<'\n';
}

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

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

vector<int> reverseArray(vector<int> &arr) {
    vector<int> ret;
    int n=arr.size();
    for (int i=n-1;i>=0;i--){
        ret.push_back(arr[i]);
    }
    return ret;
}

vector<long long> diffArray(vector<long long> &arr) {
    vector<long long> ret;
    int n=arr.size();
    for(int i=1;i<n;i++) {
        ret.push_back(arr[i] - arr[i-1]);
    }
    return ret;
}

long long sumOf(vector<long long> &arr) {
    long long ans = 0ll;
    for(long long i: arr) {
        ans+=i;
    }
    return ans;
}

void solve(){
    int n;
    cin>>n;
    vector<long long> a(n,0ll);
    for (auto &i:a) {
        cin>>i;
    }
    long long ans = sumOf(a);
    while(n>1) {
        a = diffArray(a);
        ans=max(ans, abs(sumOf(a)));
        n--;
    }
    cout<<ans<<'\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

vector<int> reverseArray(vector<int> &arr) {
    vector<int> ret;
    int n=arr.size();
    for (int i=n-1;i>=0;i--){
        ret.push_back(arr[i]);
    }
    return ret;
}

vector<int> diffArray(vector<int> &arr) {
    vector<int> ret;
    int n=arr.size();
    for(int i=1;i<n;i++) {
        ret.push_back(arr[i] - arr[i-1]);
    }
    return ret;
}

long long sumOf(vector<int> &arr) {
    long long ans = 0ll;
    for(int i: arr) {
        ans+=i;
    }
    return ans;
}

void solve(){
    int n;
    cin>>n;
    vector<int> a(n,0);
    for (int &i:a) {
        cin>>i;
    }
    long long ans = sumOf(a);
    while(n>1) {
        a = diffArray(a);
        ans=max(ans, abs(sumOf(a)));
        n--;
    }
    cout<<max(ans, 1ll*a[0])<<'\n';
}

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