ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 14):
/**
    @author: ddi4z
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

// integer vectors
typedef vector<int> vi;
typedef vector<ll> vll;

// vectors of vectors of integers
typedef vector<vi> vvi;
typedef vector<vll> vvll;

// pairs of integers
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

// vector of pairs of integers
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// stack of integers
typedef stack<int> si;

// stack of pairs of integers
typedef stack<pii> spii;

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fori(i, s, n) for(int i = s; i < n; ++i)
#define forll(i, s, n) for(ll i = s; i < n; ++i)
#define rfori(i, s, n) for(int i = s; i >= n; --i)
#define rforll(i, s, n) for(ll i = s; i >= n; --i)

const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;

#define DBG(X) cerr << #X << " = " << X << endl;
#define RAYA cerr << " ========================= " << endl;

// order statistics

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
//ordered_set order;


int mod(int a, int m) {return ((a%m) + m) % m;}

string a, b, c;

map<string, ll> memo;

ll dp(ll i,ll j){
    if (memo.count({i,j})) return memo[{i,j}];
    if (i == a.size() && j < b.size()) return memo[{i,j}] = (b[j] != c[i + j]) + dp(i, j + 1);
    if (j == b.size() && i < a.size()) return memo[{i,j}] = (a[i] != c[i + j]) + dp(i + 1, j);
    if (i == a.size() && j == b.size()) return 0;
    ll res = min((a[i] != c[i + j]) + dp(i + 1, j), (b[j] != c[i + j]) + dp(i, j + 1));
    return memo[{i,j}] = res;
}


int main() {
    ll TT;
    scanf("%lld", &TT);
    while(TT--) {
        cin >> a >> b >> c;
        memo.clear();
        printf("%lld\n", dp(0,0));
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 5):
#include<bits/stdc++.h>
using namespace std;

#define ll long long int

ll power(ll a, ll b) { if (b == 0) { return 1; } ll res = power(a, b/2); if (b%2) { return res*res*a; } else { return res*res; } }

ll lcm (ll a, ll b) { return ((a*b)/(__gcd(a,b))); }

ll cnt = 0;

ll func(string a, string b, string c, vector<vector<ll> > &dp, ll indexa, ll indexb, ll indexc) {
    cnt++;
    ll n1 = a.length();
    ll n2 = b.length();
    ll n3 = c.length();
    ll r1 = 1e9;
    ll r2 = 1e9;
    
    if (indexc == n3) {
        return 0;
    }
    if (dp[indexa][indexb] != -1) {
        return dp[indexa][indexb];
    }
    if (indexa == n1) {
        if (b[indexb] == c[indexc] && indexb<n2) {
            return dp[indexa][indexb] = func(a,b,c,dp,indexa,indexb+1, indexc+1);
        }
        else if (b[indexb] != c[indexc] && indexb<n2) {
            return dp[indexa][indexb] = 1+func(a,b,c,dp,indexa,indexb+1, indexc+1);
        }
        else {
            return 0;
        }
    }

    if (indexb == n2) {
        if (a[indexa] == c[indexc] && indexa<n1) {
            return dp[indexa][indexb] = func(a,b,c,dp,indexa+1,indexb, indexc+1);
        }
        else if (a[indexa] != c[indexc] && indexa<n1) {
            return dp[indexa][indexb] = 1+func(a,b,c,dp,indexa+1,indexb, indexc+1);
        }
        else {
            return 0;
        }
    }

    

    if (a[indexa] != c[indexc] && b[indexb] != c[indexc]) {
        r1 = 1 + func(a,b,c,dp,indexa+1, indexb, indexc+1);
        r2 = 1 + func(a,b,c,dp,indexa,indexb+1, indexc+1);
    }
    else {
        if (a[indexa] == c[indexc]) {
        r1 = func(a,b,c,dp,indexa+1, indexb, indexc+1);
        }
        else {
            r1 = 1 + func(a,b,c,dp,indexa+1, indexb,indexc+1);
        }

        if (b[indexb] == c[indexc]) {
        r2 = func(a,b,c,dp,indexa,indexb+1, indexc+1);
        }
        else {
            r2 = 1+func(a,b,c,dp,indexa, indexb+1, indexc+1);
        }        
    }
    return dp[indexa][indexb] = min(r1,r2);
}

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

    ll t;
    cin >> t;

    while(t--) {
        string a,b,c;
        cin >> a >> b >> c;
        vector<vector<ll> > dp(1001, vector<ll> (1001, -1));
        ll ans = func(a,b,c,dp,0LL,0LL,0LL);
        cout << ans << endl;
    }
    //cout << cnt << endl;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"
using namespace std;
#define ll long long
void fun(vector<int> & arr,int n , int & ans){
	if(n<1)return;
    if(n==1){
        if(abs(arr[0])>ans)ans=abs(arr[0]);
        return;
    }
	int sum=0;
	for(int i=0;i<n;i++)sum+=arr[i];
	if(abs(sum)>ans)ans=abs(sum);
    

    vector<int> newarr(n-1);
    for(int i=1;i<n;i++)newarr[i-1]=arr[i]-arr[i-1];
    fun(newarr,n-1,ans);
}

int32_t main(){
	int t;cin>>t;
	while(t--){
		int n;cin>>n;
		vector<int> arr(n);
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>arr[i];
			ans+=arr[i];
		}
		vector<int> v(n-1);
        for(int i=1;i<n;i++)v[i-1]=arr[i]-arr[i-1];
		fun(v,n-1,ans);
		cout<<ans<<endl;
		

	}
	
}

Submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"
using namespace std;
#define ll long long
void fun(vector<int> & arr,int n , ll int & ans){
	if(n<1)return;
    if(n==1){
        if(abs(arr[0])>ans)ans=abs(arr[0]);
        return;
    }
	ll int sum=0;
	for(int i=0;i<n;i++)sum+=arr[i];
	if(abs(sum)>ans)ans=abs(sum);
    

    vector<int> newarr(n-1);
    for(int i=1;i<n;i++)newarr[i-1]=arr[i]-arr[i-1];
    fun(newarr,n-1,ans);
}

int32_t main(){
	int t;cin>>t;
	while(t--){
		int n;cin>>n;
		vector<int> arr(n);
		ll int ans=0;
		for(int i=0;i<n;i++){
			cin>>arr[i];
			ans+=arr[i];
		}
		vector<int> v(n-1);
        for(int i=1;i<n;i++)v[i-1]=arr[i]-arr[i-1];
		fun(v,n-1,ans);
		cout<<ans<<endl;
		

	}
	
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 2):
#include "bits/stdc++.h"
using namespace std;
#define ll long long
void fun(vector<int> & arr,int n ,int & ans){
    if(n==1){
        if(arr[0]>ans)ans=arr[0];
        return;
    }
	int sum=0;
	for(int i=0;i<n;i++)sum+=arr[i];
	if(sum>ans)ans=sum;
    vector<int> newarr(n-1);
    for(int i=1;i<n;i++)newarr[i-1]=arr[i]-arr[i-1];
    fun(newarr,n-1,ans);
    reverse(arr.begin(),arr.end());
    vector<int> newarr2(n-1);
    for(int i=1;i<n;i++)newarr2[i-1]=arr[i]-arr[i-1];
    fun(newarr2,n-1,ans);
}

int32_t main(){
	int t;cin>>t;
	while(t--){
		int n;cin>>n;
		vector<int> arr(n);
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>arr[i];
			ans+=arr[i];
		}
		fun(arr,n,ans);
		cout<<ans<<endl;
		

	}
	
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"
using namespace std;
#define ll long long
void fun(vector<int> & arr,int n , ll int & ans){
	if(n<1)return;
    if(n==1){
        if(abs(arr[0])>ans)ans=abs(arr[0]);
        return;
    }
	ll int sum=0;
	for(int i=0;i<n;i++)sum+=arr[i];
	if(abs(sum)>ans)ans=abs(sum);
    

    vector<int> newarr(n-1);
    for(int i=1;i<n;i++)newarr[i-1]=arr[i]-arr[i-1];
    fun(newarr,n-1,ans);
}

int32_t main(){
	int t;cin>>t;
	while(t--){
		int n;cin>>n;
		vector<int> arr(n);
		ll int ans=0;
		for(int i=0;i<n;i++){
			cin>>arr[i];
			ans+=arr[i];
		}
		vector<int> v(n-1);
        for(int i=1;i<n;i++)v[i-1]=arr[i]-arr[i-1];
		fun(v,n-1,ans);
		cout<<ans<<endl;
		

	}
	
}

Submission (verdict: Accepted):
#include "bits/stdc++.h"
using namespace std;
#define ll long long
void fun(vector<ll int> & arr,int n , ll int & ans){
	if(n<1)return;
    if(n==1){
        if(abs(arr[0])>ans)ans=abs(arr[0]);
        return;
    }
	ll int sum=0;
	for(int i=0;i<n;i++)sum+=arr[i];
	if(abs(sum)>ans)ans=abs(sum);
    

    vector<ll int> newarr(n-1);
    for(int i=1;i<n;i++)newarr[i-1]=arr[i]-arr[i-1];
    fun(newarr,n-1,ans);
}

int32_t main(){
	int t;cin>>t;
	while(t--){
		int n;cin>>n;
		vector<ll int> arr(n);
		ll int ans=0;
		for(int i=0;i<n;i++){
			cin>>arr[i];
			ans+=arr[i];
		}
		vector<ll int> v(n-1);
        for(int i=1;i<n;i++)v[i-1]=arr[i]-arr[i-1];
		fun(v,n-1,ans);
		cout<<ans<<endl;
		

	}
	
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
#include "bits/stdc++.h"
using namespace std;
#define ll long long
void fun(vector<int> & arr,int n ,int & ans){
    if(n==1){
        if(arr[0]>ans)ans=arr[0];
        return;
    }
	int sum=0;
	for(int i=0;i<n;i++)sum+=arr[i];
	if(sum>ans)ans=sum;
    vector<int> newarr(n-1);
    for(int i=1;i<n;i++)newarr[i-1]=arr[i]-arr[i-1];
    fun(newarr,n-1,ans);
    reverse(arr.begin(),arr.end());
    vector<int> newarr2(n-1);
    for(int i=1;i<n;i++)newarr2[i-1]=arr[i]-arr[i-1];
    fun(newarr2,n-1,ans);
}

int32_t main(){
	int t;cin>>t;
	while(t--){
		int n;cin>>n;
		vector<int> arr(n);
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>arr[i];
			ans+=arr[i];
		}
		fun(arr,n,ans);
		cout<<ans<<endl;
		

	}
	
}

Submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"
using namespace std;
#define ll long long
void fun(vector<int> & arr,int n , int & ans){
	if(n<1)return;
    if(n==1){
        if(abs(arr[0])>ans)ans=abs(arr[0]);
        return;
    }
	int sum=0;
	for(int i=0;i<n;i++)sum+=arr[i];
	if(abs(sum)>ans)ans=abs(sum);
    

    vector<int> newarr(n-1);
    for(int i=1;i<n;i++)newarr[i-1]=arr[i]-arr[i-1];
    fun(newarr,n-1,ans);
}

int32_t main(){
	int t;cin>>t;
	while(t--){
		int n;cin>>n;
		vector<int> arr(n);
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>arr[i];
			ans+=arr[i];
		}
		vector<int> v(n-1);
        for(int i=1;i<n;i++)v[i-1]=arr[i]-arr[i-1];
		fun(v,n-1,ans);
		cout<<ans<<endl;
		

	}
	
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int dp(string a, string b, string c, int ia, int ib, vector<vector<int>> arr)
{
    if (ia == a.size() && ib == b.size())
    {
        return 0;
    }

    int left = INT_MAX, right = INT_MAX;

    if (ia < a.size())
    {
        if (arr[ia][ib] != -1)
        {
            left = arr[ia + 1][ib] + (a[ia] != c[ia + ib]);
        }
        else
        {
            left = dp(a, b, c, ia + 1, ib, arr) + (a[ia] != c[ia + ib]);
        }
    }
    if (ib < b.size())
    {
        if (arr[ia][ib] != -1)
        {
            right = arr[ia][ib + 1] + (b[ib] != c[ia + ib]);
        }
        else
        {
            right = dp(a, b, c, ia, ib + 1, arr) + (b[ib] != c[ia + ib]);
        }
    }

    arr[ia][ib] = min(left, right);
    return arr[ia][ib];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        string a, b, c;
        cin >> a >> b >> c;

        vector<vector<int>> arr(a.size() + 1, vector<int>(b.size() + 1, -1));

        cout << dp(a, b, c, 0, 0, arr) << endl;
    }

    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int dp(string a, string b, string c, int ia, int ib, vector<vector<int>> arr)
{
    if (ia == a.size() && ib == b.size())
    {
        return 0;
    }

    int left = INT_MAX, right = INT_MAX;

    if (ia < a.size())
    {
        if (arr[ia + 1][ib] != -1)
        {
            left = arr[ia + 1][ib] + (a[ia] != c[ia + ib]);
        }
        else
        {
            left = dp(a, b, c, ia + 1, ib, arr) + (a[ia] != c[ia + ib]);
        }
    }
    if (ib < b.size())
    {
        if (arr[ia][ib + 1] != -1)
        {
            right = arr[ia][ib + 1] + (b[ib] != c[ia + ib]);
        }
        else
        {
            right = dp(a, b, c, ia, ib + 1, arr) + (b[ib] != c[ia + ib]);
        }
    }

    arr[ia][ib] = min(left, right);
    return arr[ia][ib];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        string a, b, c;
        cin >> a >> b >> c;

        vector<vector<int>> arr(a.size() + 1, vector<int>(b.size() + 1, -1));

        cout << dp(a, b, c, 0, 0, arr) << endl;
    }

    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int dp(string a, string b, string c, int ia, int ib, vector<vector<int>> arr)
{
    if (ia == a.size() && ib == b.size())
    {
        return 0;
    }

    int left = INT_MAX, right = INT_MAX;

    if (ia < a.size())
    {
        if (arr[ia + 1][ib] != -1)
        {
            left = arr[ia + 1][ib] + (a[ia] != c[ia + ib]);
        }
        else
        {
            left = dp(a, b, c, ia + 1, ib, arr) + (a[ia] != c[ia + ib]);
        }
    }
    if (ib < b.size())
    {
        if (arr[ia][ib + 1] != -1)
        {
            right = arr[ia][ib + 1] + (b[ib] != c[ia + ib]);
        }
        else
        {
            right = dp(a, b, c, ia, ib + 1, arr) + (b[ib] != c[ia + ib]);
        }
    }

    arr[ia][ib] = min(left, right);
    return arr[ia][ib];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        string a, b, c;
        cin >> a >> b >> c;

        vector<vector<int>> arr(a.size() + 1, vector<int>(b.size() + 1, -1));

        cout << dp(a, b, c, 0, 0, arr) << endl;
    }

    return 0;
}

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

typedef long long ll;

int dp(string &a, string &b, string &c, int ia, int ib, vector<vector<int>> &arr)
{
    if (ia == a.size() && ib == b.size())
    {
        return 0;
    }

    if (arr[ia][ib] != -1)
    {
        return arr[ia][ib];
    }

    int left = INT_MAX, right = INT_MAX;

    if (ia < a.size())
    {
        if (arr[ia + 1][ib] != -1)
        {
            left = arr[ia + 1][ib] + (a[ia] != c[ia + ib]);
        }
        else
        {
            left = dp(a, b, c, ia + 1, ib, arr) + (a[ia] != c[ia + ib]);
        }
    }
    if (ib < b.size())
    {
        if (arr[ia][ib + 1] != -1)
        {
            right = arr[ia][ib + 1] + (b[ib] != c[ia + ib]);
        }
        else
        {
            right = dp(a, b, c, ia, ib + 1, arr) + (b[ib] != c[ia + ib]);
        }
    }

    arr[ia][ib] = min(left, right);
    return arr[ia][ib];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        string a, b, c;
        cin >> a >> b >> c;

        vector<vector<int>> arr(a.size() + 1, vector<int>(b.size() + 1, -1));

        cout << dp(a, b, c, 0, 0, arr) << endl;
    }

    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int dp(string a, string b, string c, int ia, int ib, vector<vector<int>> arr)
{
    if (ia == a.size() && ib == b.size())
    {
        return 0;
    }

    int left = INT_MAX, right = INT_MAX;

    if (ia < a.size())
    {
        if (arr[ia][ib] != -1)
        {
            left = arr[ia + 1][ib] + (a[ia] != c[ia + ib]);
        }
        else
        {
            left = dp(a, b, c, ia + 1, ib, arr) + (a[ia] != c[ia + ib]);
        }
    }
    if (ib < b.size())
    {
        if (arr[ia][ib] != -1)
        {
            right = arr[ia][ib + 1] + (b[ib] != c[ia + ib]);
        }
        else
        {
            right = dp(a, b, c, ia, ib + 1, arr) + (b[ib] != c[ia + ib]);
        }
    }

    arr[ia][ib] = min(left, right);
    return arr[ia][ib];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        string a, b, c;
        cin >> a >> b >> c;

        vector<vector<int>> arr(a.size() + 1, vector<int>(b.size() + 1, -1));

        cout << dp(a, b, c, 0, 0, arr) << endl;
    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

    #include<unistd.h>

    #include<thread>

    using namespace std;

    #define ld double

    #define ll long long

    #define pb emplace_back

    #define mk make_pair

    #define mod 1000000007

    #define ff first

    #define ss second

    #define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    #define all(x) x.begin(),x.end()

    #define sz(v) (int)v.size()

    #define int long long

    const int mxn =1e6+5;

    int X[]={1,-1,0,0};

    int Y[]={0,0,1,-1};

    char dir[]={'D','U','R','L'};

     

     

    ll gcd(ll a,ll b){

            while(b){

                a%=b;

                swap(a,b);

            }

            return a;

    }

        // _________________________________________Sieve________________________________________

    vector<int> prime;

    void sieve(){

            int vis[mxn];

            memset(vis,0,sizeof(vis));

            for(int i=2;i<mxn;i++){

                if(vis[i]==0)

                    prime.push_back(i);

                for(int j=i;j<mxn;j+=i){

                    if(vis[j]==0){

                        vis[j]=1;

                    }

                }

            }

    }

        // _________________________________________Power_________________________________________

    ll power(ll a,ll b){

            ll ans =1;

            while(b>0){

                if(b&1)ans = ans*a;

                a = a*a;

                b>>=1;

            }

            return ans;

    }

     

    // -------------------------------------------Code--------------------------------------------- 

    

    void solve(){

      int n,l,r;

      cin>>n>>l>>r;

      vector<int>ar(n);

      for( int &i :ar){

        cin>>i;

      }

      sort(ar.begin(),ar.begin()+l);

      sort(ar.begin()+l,ar.begin()+r);

      sort(ar.begin()+r,ar.end());

      int k=0;

      int sum=0;

      int ans =0;

      for(int i=r-1;i>=l-1;i--){

        if(k<l-1 && ar[k]<ar[i]){

          sum+=ar[k];

          k++;

        }

        else{

          sum+=ar[i];

        }

      }

      ans = sum;

      k = r;

      sum=0;

      

      for(int i=r-1;i>=l-1;i--){

        if(k<n &&ar[k]<ar[i]){

          

          sum+=ar[k];

          k++;

        }

        else{

          sum+=ar[i];

        }

      }

      ans = min(ans,sum);

      cout<<ans<<"\n";

      

    }      

     

     

    int32_t main(){ 

            FIO

            int t;

            cin>>t;

            

            // t = 1;

            while(t--){

                // tt++;

                solve();

                // cout<<"Case #"<<tt<<" ";

            }

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


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int maxn = 2e5+3;
ll i,j,p,q,n,m,k,t,a[maxn],ans,b[maxn];
void solve()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    if(n==1)
    {
        cout<<a[1]<<endl;
        return ;
    }
    ans = -LLONG_MAX;
    for(i=1;i<=n;i++){
        p = 0;
        for(j=1;j<=n-i+1;j++)
            p+=a[j];
        ans = max(ans,p);
        ans = max(ans,-p);
        for(j=1;j<(n-i+1);j++){
            b[j] = a[j+1]-a[j];
        }
        for(j=1;j<(n-i+1);j++)
            a[j] = b[j];
    }
    ans = max(ans,a[1]);
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>t;
    while(t--)
        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>
#define endl '\n'
using namespace std;
typedef long long ll;
const int maxn = 2e5+3;
ll i,j,p,q,n,m,k,t,a[maxn],ans,b[maxn];
void solve()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    if(n==1)
    {
        cout<<a[1]<<endl;
        return ;
    }
    ans = -LLONG_MAX;
    for(i=1;i<=n;i++){
        p = 0;
        for(j=1;j<=n-i+1;j++)
            p+=a[j];
        ans = max(ans,p);
        ans = max(ans,-p);
        for(j=1;j<(n-i+1);j++){
            b[j] = a[j+1]-a[j];
        }
        for(j=1;j<(n-i+1);j++)
            a[j] = b[j];
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>t;
    while(t--)
        solve();
    return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int maxn = 2e5+3;
ll i,j,p,q,n,m,k,t,a[maxn],ans,b[maxn];
void solve()
{
    cin>>n;
    ans = 0;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ans+=a[i];
    }
    for(i=n;i>=2;i--){
        ans = max(ans,a[i]-a[1]);
        ans = max(ans,a[1]-a[i]);
        p = a[i] - a[i-1];
        q = a[2] - a[1];
        if(p-q<q-p){
            for(j=1;j<=i;j++)
                b[j] = a[i-j+1];
        }
        else{
            for(j=1;j<=i;j++)
                b[j] = a[j];
        }
        for(j=1;j<i;j++)
            a[j] = b[j+1]-b[j];

    }
    ans = max(ans,a[1]);
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>t;
    while(t--)
        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>
#define endl '\n'
using namespace std;
typedef long long ll;
const int maxn = 2e5+3;
ll i,j,p,q,n,m,k,t,a[maxn],ans,b[maxn];
void solve()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    if(n==1)
    {
        cout<<a[1]<<endl;
        return ;
    }
    ans = -LLONG_MAX;
    for(i=1;i<=n;i++){
        p = 0;
        for(j=1;j<=n-i+1;j++)
            p+=a[j];
        ans = max(ans,p);
        ans = max(ans,-p);
        for(j=1;j<(n-i+1);j++){
            b[j] = a[j+1]-a[j];
        }
        for(j=1;j<(n-i+1);j++)
            a[j] = b[j];
    }
    ans = max(ans,a[1]);
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>t;
    while(t--)
        solve();
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int maxn = 2e5+3;
ll i,j,p,q,n,m,k,t,a[maxn],ans,b[maxn];
void solve()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    if(n==1)
    {
        cout<<a[1]<<endl;
        return ;
    }
    ans = -LLONG_MAX;
    for(i=1;i<=n;i++){
        p = 0;
        for(j=1;j<=n-i+1;j++)
            p+=a[j];
        ans = max(ans,p);
        ans = max(ans,-p);
        for(j=1;j<(n-i+1);j++){
            b[j] = a[j+1]-a[j];
        }
        for(j=1;j<(n-i+1);j++)
            a[j] = b[j];
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>t;
    while(t--)
        solve();
    return 0;
}