ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


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

using namespace std;

int T,n;

string s;

int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0); 

	cin>>T;

    while(T--){

	    cin>>n>>s;

	    bool f=0;

	    s=' '+s;

	    for(int i=1;i<=n;i++){

	        for(int j=1;j<=n;j++){

	            if(s[i]=='s'&&s[j]=='p'&&i&&j!=n){

	                f=1;

	                break;

	            }

	        }

	        if(f) break;

	    }

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

	    else cout<<"YES"<<"\n";

    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

int T,n;

string s;

int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0); 

	cin>>T;

    while(T--){

	    cin>>n>>s;

	    bool f=0;

	    s=' '+s;

	    for(int i=1;i<=n;i++){

	        for(int j=1;j<=n;j++){

	            if(s[i]=='s'&&s[j]=='p'&&i&&j!=n){

	                f=1;

	                break;

	            }

	        }

	        if(f) break;

	    }

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

	    else cout<<"YES"<<"\n";

    }

    return 0;

}

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

using namespace std;

int T,n;

string s;

int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0); 

	cin>>T;

    while(T--){

	    cin>>n>>s;

	    bool f=0;

	    s=' '+s;

	    for(int i=1;i<=n;i++){

	        for(int j=1;j<=n;j++){

	            if(s[i]=='s'&&s[j]=='p'&&i>0&&j!=n){

	                f=1;

	                break;

	            }

	        }

	        if(f) break;

	    }

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

	    else cout<<"YES"<<"\n";

    }

    return 0;

}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#define int long long
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define Frein freopen("input.in", "r", stdin);
#define Freout freopen("output.in", "w", stdout);
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 1;
int mn = 1e18;
void rec(int i, int j, string &a, string &b,string &c, string ans){
    if(i == a.size() || j == b.size()){
        while(j < b.size()) ans += b[j++];
        while(i < a.size()) ans += a[i++];
            int cnt = 0;
            for(int k = 0; k < c.size(); k++) cnt += (c[k] != ans[k]);
            mn = min(mn, cnt);
        return;
    }
    rec(i+1, j, a, b, c, ans+a[i]);
    rec(i, j+1, a, b, c, ans+b[j]);
}
void solve()
{
    string a, b, c; cin >> a >> b >> c;
    rec(0,0,a,b,c,"");
    cout << mn << "\n";
    mn = 1e18;

}
signed main()
{
FAST
    long long test_cases ;
    cin >> test_cases ;
    while (test_cases--)
    solve();
return 0;
}



Submission (verdict: Runtime error on test 2):
#include <bits/stdc++.h>
#define int long long
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define Frein freopen("input.in", "r", stdin);
#define Freout freopen("output.in", "w", stdout);
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 1;
void solve()
{
    string a, b, c; cin >> a >> b >> c;
    int n = a.size(), m =b.size();
    vector<vector<int>>dp(n+1, vector<int>(m+1, 1e18));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++)dp[i][0] = dp[i-1][0] + (a[i-1] != c[i-1]);
    for(int i = 1; i <= n; i++)dp[0][i] = dp[0][i-1] + (b[i-1] != c[i-1]);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            dp[i][j] = min(dp[i-1][j] + (a[i-1]!=c[i+j-1]), dp[i][j-1] + (b[j-1]!= c[i+j-1]));
        }   
    }

    cout << dp[n][m] << "\n";


}
signed main()
{
FAST
    long long test_cases ;
    cin >> test_cases ;
    while (test_cases--)
    solve();
return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 2):
#include <bits/stdc++.h>
#define int long long
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define Frein freopen("input.in", "r", stdin);
#define Freout freopen("output.in", "w", stdout);
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 1;
void solve()
{
    string a, b, c; cin >> a >> b >> c;
    int n = a.size(), m =b.size();
    vector<vector<int>>dp(n+1, vector<int>(m+1, 1e18));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++)dp[i][0] = dp[i-1][0] + (a[i-1] != c[i-1]);
    for(int i = 1; i <= n; i++)dp[0][i] = dp[0][i-1] + (b[i-1] != c[i-1]);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            dp[i][j] = min(dp[i-1][j] + (a[i-1]!=c[i+j-1]), dp[i][j-1] + (b[j-1]!= c[i+j-1]));
        }   
    }

    cout << dp[n][m] << "\n";


}
signed main()
{
FAST
    long long test_cases ;
    cin >> test_cases ;
    while (test_cases--)
    solve();
return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define int long long
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define Frein freopen("input.in", "r", stdin);
#define Freout freopen("output.in", "w", stdout);
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 1;
void solve()
{
    string a, b, c; cin >> a >> b >> c;
    int n = a.size(), m =b.size();
    vector<vector<int>>dp(n+1, vector<int>(m+1, 1e18));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++)dp[i][0] = dp[i-1][0] + (a[i-1] != c[i-1]);
    for(int i = 1; i <= m; i++)dp[0][i] = dp[0][i-1] + (b[i-1] != c[i-1]);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            dp[i][j] = min(dp[i-1][j] + (a[i-1]!=c[i+j-1]), dp[i][j-1] + (b[j-1]!= c[i+j-1]));
        }   
    }

    cout << dp[n][m] << "\n";
    

}
signed main()
{
FAST
    long long test_cases ;
    cin >> test_cases ;
    while (test_cases--)
    solve();
return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#define int long long
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define Frein freopen("input.in", "r", stdin);
#define Freout freopen("output.in", "w", stdout);
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 1;
int mn = 1e18;
void rec(int i, int j, string &a, string &b,string &c, string ans){
    if(i == a.size() || j == b.size()){
        while(j < b.size()) ans += b[j++];
        while(i < a.size()) ans += a[i++];
            int cnt = 0;
            for(int k = 0; k < c.size(); k++) cnt += (c[k] != ans[k]);
            mn = min(mn, cnt);
        return;
    }
    rec(i+1, j, a, b, c, ans+a[i]);
    rec(i, j+1, a, b, c, ans+b[j]);
}
void solve()
{
    string a, b, c; cin >> a >> b >> c;
    rec(0,0,a,b,c,"");
    cout << mn << "\n";
    mn = 1e18;

}
signed main()
{
FAST
    long long test_cases ;
    cin >> test_cases ;
    while (test_cases--)
    solve();
return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vector<int> a(n);
        for (auto &i : a){
            cin >> i;
        }
        a.insert(a.begin(), INT_MAX);
        a.push_back(-1);
        int f = 1;
        for (int i = 0; i < n-1; i++){
            if (a[i] > a[i+1] && a[i+1] > a[i+2]){
                f--;
                break;
            }
        }
        if (f){
            cout << "YES" << endl;
            continue;
        }
        cout << "NO" << endl;
    }
    
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vector<int> a(n);
        for (auto &i : a){
            cin >> i;
        }
        a.insert(a.begin(), INT_MAX);
        a.push_back(-1);
        int f = 1;
        for (int i = 0; i < n-1; i++){
            if (a[i] > a[i+1] && a[i+1] > a[i+2]){
                f--;
                break;
            }
        }
        if (f){
            cout << "YES" << endl;
            continue;
        }
        cout << "NO" << endl;
    }
    
}

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        deque<int> a(n);
        for (auto &i : a){
            cin >> i;
        }
        int f = 1;
        while (a.size() > 1){
            if (a[0] > a[1]){
                f = 0;
                break;
            }
            a[1] -= a[0];
            a.pop_front();
            if (a[0] == a[1]){
                a.pop_back();
            }
        }
    }
    
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        deque<int> a(n);
        for (auto &i : a){
            cin >> i;
        }
        int f = 1;
        while (a.size() > 1){
            if (a[0] > a[1]){
                f = 0;
                break;
            }
            a[1] -= a[0];
            a.pop_front();
            if (a[0] == a[1]){
                a.pop_back();
            }
        }
    }
    
}

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        deque<int> a(n);
        for (auto &i : a){
            cin >> i;
        }
        int f = 1;
        while (a.size() > 1){
            if (a[0] > a[1]){
                f = 0;
                cout << "NO" << endl;
                break;
            }
            a[1] -= a[0];
            a.pop_front();
            if (a[0] == a[1]){
                a.pop_back();
            }
        }
        if (f){
            cout << "YES" << endl;
        }
    }
    
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        deque<int> a(n);
        for (auto &i : a){
            cin >> i;
        }
        int f = 1;
        while (a.size() > 1){
            if (a[0] > a[1]){
                f = 0;
                cout << "NO" << endl;
                break;
            }
            a[1] -= a[0];
            a.pop_front();
            if (a[0] == a[1]){
                a.pop_back();
            }
        }
        if (f){
            cout << "YES" << endl;
        }
    }
    
}

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        deque<int> a(n);
        for (auto &i : a){
            cin >> i;
        }
        int f = 1;
        while (a.size() > 1){
            if (a[0] > a[1]){
                f = 0;
                cout << "NO" << endl;
                break;
            }
            else if (a[0] == a[1]){
                a.pop_front();
                a.pop_front();
            }
            else{
                a[1] -= a[0];
                a.pop_front();
            }


        }
        if (f){
            cout << "YES" << endl;
        }
    }
    
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
int tci = 0;

bool rec(int x, multiset<int> &values) {
	int h1 = x / 2, h2 = x - x / 2;
	int c1 = values.count(h1);
	int c2 = values.count(h2);

	// if (tci == 6)
	// 	cout << x << " " << h1 << " " << h2 << " " << c1 << " " << c2 << " " << values.count(x) << "\n";
	if (values.count(x)) {
		values.erase(values.find(x));
		return true;
	} else if (x == 1) {
		return false;
	} else if (c1 && c2) {
		return (h1 == h2 ? c1 >= 2: true) && rec(h1, values) && rec(h2, values);
	} else {
		return rec(h1, values) && rec(h2, values);
	}

	return false;
}

void solve()
{
	int n, m, x;
	cin >> n >> m;
	multiset<int> values;
	for (int i = 0; i < n; i++) {
		cin >> x;
		values.insert(x);
	}

	bool ans = true;
	for (int i = 0; i < m; i++) {
		cin >> x;
		if (!rec(x, values)) {
			ans = false;
		}
	}

	cout << (ans && !values.size() ? "Yes\n": "No\n");
}

int main()
{
	int tc;
	cin >> tc;

	for(tci = 0; tci < tc; tci++) {
		// cout << "Case #" << tci + 1 << ": ";
		solve();
	}

	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
int tci = 1;

bool rec(int x, multiset<int> &values) {
	if (values.count(x)) {
		values.erase(values.find(x));
		return true;
	} else if (x == 1) {
		return false;
	} else {
		return rec(x / 2, values) && rec(x - x / 2, values);
	}

	return false;
}

void solve()
{
	int n, m, x;
	cin >> n >> m;
	multiset<int> values;
	for (int i = 0; i < n; i++) {
		cin >> x;
		values.insert(x);
	}

	bool ans = true;
	for (int i = 0; i < m; i++) {
		cin >> x;
		if (!rec(x, values)) {
			ans = false;
		}
	}

	cout << (ans && !values.size() ? "Yes\n": "No\n");
}

int main()
{
	int tc;
	cin >> tc;

	for(tci = 1; tci <= tc; tci++) {
		// cout << "Case #" << tci + 1 << ": ";
		solve();
	}

	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
int tci = 0;

bool rec(int x, multiset<int> &values) {
	int h1 = x / 2, h2 = x - x / 2;
	int c1 = values.count(h1);
	int c2 = values.count(h2);

	// if (tci == 6)
	// 	cout << x << " " << h1 << " " << h2 << " " << c1 << " " << c2 << " " << values.count(x) << "\n";
	if (values.count(x)) {
		values.erase(values.find(x));
		return true;
	} else if (x == 1) {
		return false;
	} else if (c1 && c2) {
		return (h1 == h2 ? c1 >= 2: true) && rec(h1, values) && rec(h2, values);
	} else {
		return rec(h1, values) && rec(h2, values);
	}

	return false;
}

void solve()
{
	int n, m, x;
	cin >> n >> m;
	multiset<int> values;
	for (int i = 0; i < n; i++) {
		cin >> x;
		values.insert(x);
	}

	bool ans = true;
	for (int i = 0; i < m; i++) {
		cin >> x;
		if (!rec(x, values)) {
			ans = false;
		}
	}

	cout << (ans && !values.size() ? "Yes\n": "No\n");
}

int main()
{
	int tc;
	cin >> tc;

	for(tci = 0; tci < tc; tci++) {
		cout << "Case #" << tci + 1 << ": ";
		solve();
	}

	return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
int tci = 0;

bool rec(int x, multiset<int> &values) {
	int h1 = x / 2, h2 = x - x / 2;
	int c1 = values.count(h1);
	int c2 = values.count(h2);

	// if (tci == 6)
	// 	cout << x << " " << h1 << " " << h2 << " " << c1 << " " << c2 << " " << values.count(x) << "\n";
	if (values.count(x)) {
		values.erase(values.find(x));
		return true;
	} else if (x == 1) {
		return false;
	} else if (c1 && c2) {
		return (h1 == h2 ? c1 >= 2: true) && rec(h1, values) && rec(h2, values);
	} else {
		return rec(h1, values) && rec(h2, values);
	}

	return false;
}

void solve()
{
	int n, m, x;
	cin >> n >> m;
	multiset<int> values;
	for (int i = 0; i < n; i++) {
		cin >> x;
		values.insert(x);
	}

	bool ans = true;
	for (int i = 0; i < m; i++) {
		cin >> x;
		if (!rec(x, values)) {
			ans = false;
		}
	}

	cout << (ans && !values.size() ? "Yes\n": "No\n");
}

int main()
{
	int tc;
	cin >> tc;

	for(tci = 0; tci < tc; tci++) {
		// cout << "Case #" << tci + 1 << ": ";
		solve();
	}

	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
int tci = 0;

bool rec(int x, multiset<int> &values) {
	int h1 = x / 2, h2 = x - x / 2;
	int c1 = values.count(h1);
	int c2 = values.count(h2);

	// if (tci == 6)
	// 	cout << x << " " << h1 << " " << h2 << " " << c1 << " " << c2 << " " << values.count(x) << "\n";
	if (values.count(x)) {
		values.erase(values.find(x));
		return true;
	} else if (x == 1) {
		return false;
	} else if (c1 && c2) {
		return (h1 == h2 ? c1 >= 2: true) && rec(h1, values) && rec(h2, values);
	} else {
		return rec(h1, values) && rec(h2, values);
	}

	return false;
}

void solve()
{
	int n, m, x;
	cin >> n >> m;
	multiset<int> values;
	for (int i = 0; i < n; i++) {
		cin >> x;
		values.insert(x);
	}

	bool ans = true;
	for (int i = 0; i < m; i++) {
		cin >> x;
		if (!rec(x, values)) {
			ans = false;
		}
	}

	cout << (ans && !values.size() ? "Yes\n": "No\n");
}

int main()
{
	int tc;
	cin >> tc;

	for(tci = 0; tci < tc; tci++) {
		cout << "Case #" << tci + 1 << ": ";
		solve();
	}

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

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
void ans(){
    int n; cin>>n;
    vector<ll>v(n);
    long long s=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        s+=v[i];
    }
    if(n==1){
        cout<<s<<endl;
        return;
    }
    s=abs(s);
    
    for(int i=0;i<n;i++){
        long long sum=0;
        for(int j=0;j<n-i-1;j++){
           
            v[j]=v[j+1]-v[j];
             sum+=v[j];
            // cout<<v[j]<<" ";
        }
        // sum=abs(sum);
        // cout<<sum<<" ";
        // cout<<endl;
        s=max(s,abs(sum));
    }
    cout<<s<<endl;

}

int main(){
    int t;cin>>t;
    while(t--){
        ans();
    }
    return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
void ans(){
    int n; cin>>n;
    vector<ll>v(n);
    long long s=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        s+=v[i];
    }
    if(n==1){
        cout<<s<<endl;
        return;
    }
    // s=s;
    
    for(int i=0;i<n;i++){
        long long sum=0;
        for(int j=0;j<n-i-1;j++){
           
            v[j]=v[j+1]-v[j];
             sum+=v[j];
            // cout<<v[j]<<" ";
        }
        // sum=abs(sum);
        // cout<<sum<<" ";
        // cout<<endl;
        s=max(s,abs(sum));
    }
    cout<<s<<endl;

}

int main(){
    int t;cin>>t;
    while(t--){
        ans();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
void ans(){
    int n; cin>>n;
    vector<int>v(n);
    long long s=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        s+=v[i];
    }
    if(n==1){
        cout<<s<<endl;
        return;
    }
    s=abs(s);
    
    for(int i=0;i<n;i++){
        long long sum=0;
        for(int j=0;j<n-i-1;j++){
           
            v[j]=v[j+1]-v[j];
             sum+=v[j];
            // cout<<v[j]<<" ";
        }
        // sum=abs(sum);
        // cout<<sum<<" ";
        // cout<<endl;
        s=max(s,abs(sum));
    }
    cout<<s<<endl;

}

int main(){
    int t;cin>>t;
    while(t--){
        ans();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
void ans(){
    int n; cin>>n;
    vector<int>v(n);
    long long s=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        s+=v[i];
    }
    if(n==1){
        cout<<s<<endl;
        return;
    }
    s=abs(s);
    
    for(int i=0;i<n;i++){
        long long sum=0;
        for(int j=0;j<n-i-1;j++){
           
            v[j]=v[j+1]-v[j];
             sum+=v[j];
            // cout<<v[j]<<" ";
        }
        // sum=abs(sum);
        // cout<<sum<<" ";
        // cout<<endl;
        s=max(s,abs(sum));
    }
    cout<<s<<endl;

}

int main(){
    int t;cin>>t;
    while(t--){
        ans();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
void ans(){
    int n; cin>>n;
    vector<ll>v(n);
    long long s=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        s+=v[i];
    }
    if(n==1){
        cout<<s<<endl;
        return;
    }
    s=abs(s);
    
    for(int i=0;i<n;i++){
        long long sum=0;
        for(int j=0;j<n-i-1;j++){
           
            v[j]=v[j+1]-v[j];
             sum+=v[j];
            // cout<<v[j]<<" ";
        }
        // sum=abs(sum);
        // cout<<sum<<" ";
        // cout<<endl;
        s=max(s,abs(sum));
    }
    cout<<s<<endl;

}

int main(){
    int t;cin>>t;
    while(t--){
        ans();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

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];
        }
        bool change = false;
        while(n>0 && !change){
            change = true;
            for(int i=0; i<n-1; i++){
                if(a[i]>0 && a[i]<=a[i+1]){
                    a[i+1] -= a[i];
                    a[i] = 0;
                    change = false;
                }
            }
            n--;
        }
        bool ok = true;
        for(int i=0; i<n-1; i++){
            if(a[i] > a[i+1]){
                ok = false;
                break;
            }
        }
        cout << (ok ? "yes" : "no") << endl;
    }

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

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];
        }
        bool change = false;
        while(n>0 && !change){
            change = true;
            for(int i=0; i<n-1; i++){
                if(a[i]>0 && a[i]<=a[i+1]){
                    a[i+1] -= a[i];
                    a[i] = 0;
                    change = false;
                }
            }
            n--;
        }
        bool ok = true;
        for(int i=0; i<n-1; i++){
            if(a[i] > a[i+1]){
                ok = false;
                break;
            }
        }
        cout << (ok ? "yes" : "no") << endl;
    }

}

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

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];
        }
        bool change = true;
        for(int i=0; i<n-2; i++){
            if(a[i] > a[i+1]){
                change = false;
                break;
            }else{
                a[i+1] -= a[i];
                a[i] = 0;
            }
        }
        if(!change){
            cout << "no" << endl;
        }else{
            cout << "yes" << endl;
        }
    }
}