ShaysXIA/CodeInsightBench huggingface dataset:
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;

vector<long long> findDigits(long long n) {
    vector<long long> digits(19, 0); // To store digits of the number
    int i = 1;
    while (i<=18) {
        digits[i] = n % 10; // Extract the last digit
        n /= 10;            // Remove the last digit
        i++;
    }
    return digits;
}

int main() {
    long long t;
    cin >> t;

    while (t--) {
        long long n;
        cin >> n;
        int ct1=0;
        int ct2=0;
        if(n%9==0){
            cout<<"YES";
            cout<<endl;
            continue;
        }

        vector<long long> digits = findDigits(n);
        long long sum = 0;
                for (long long i = 0; i < 19; i++) {
            if(digits[i]==3){
                ct1++;
            }
                        if(digits[i]==2){
                ct2++;
            }
        }
         
        // Calculate the sum of digits
        for (long long i = 0; i < 19; i++) {
            sum += digits[i];
        }

        // Check the condition

    bool f=true;
    for(int i=0;i<=ct2&&f;i++){
        for(int j=0;j<=ct1;j++){
            if((sum+i*2+j*6)%9==0){
                cout<<"YES";
                cout<<endl;

                f=false;
                break;
            }
        }
    }
    if(f){
        cout<<"NO";
        cout<<endl;
    }
    }

    return 0;
}


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

vector<long long> findDigits(long long n) {
    vector<long long> digits((int)1e5+1, 0); // To store digits of the number
    int i = 1;
    while (i<=18) {
        digits[i] = n % 10; // Extract the last digit
        n /= 10;            // Remove the last digit
        i++;
    }
    return digits;
}

int main() {
    long long t;
    cin >> t;

    while (t--) {
        long long n;
        cin >> n;
        int ct1=0;
        int ct2=0;
        if(n%9==0){
            cout<<"YES";
            cout<<endl;
            continue;
        }

        vector<long long> digits = findDigits(n);
        long long sum = 0;
                for (long long i = 0; i < (int)1e5+1; i++) {
            if(digits[i]==3){
                ct1++;
            }
                        if(digits[i]==2){
                ct2++;
            }
        }
         
        // Calculate the sum of digits
        for (long long i = 0; i < (int)1e5+1; i++) {
            sum += digits[i];
        }

        // Check the condition

    bool f=true;
    for(int i=0;i<=ct2&&f;i++){
        for(int j=0;j<=ct1;j++){
            if((sum+i*2+j*6)%9==0){
                cout<<"YES";
                cout<<endl;

                f=false;
                break;
            }
        }
    }
    if(f){
        cout<<"NO";
        cout<<endl;
    }
    }

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 8):
#include <iostream>
#include <string>
using namespace std;

void solve(string s) {
    long long n = s.size();
    bool updated = true;

    while (updated) {
        updated = false;
        for (long long i = n - 1; i > 0; --i) {
            if (s[i] > s[i - 1] + 1) {
                s[i]--;
                swap(s[i], s[i - 1]);
                updated = true;  // Mark as updated to repeat the process
            }
        }
    }

    cout << s;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        solve(s);
        cout << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<string>
using namespace std;

int main(){
int t;
cin>>t;
while(t--){
    string n;
    cin>>n;
    int change(1);
    while(change!=0){
        change=0;
        for(int i=1;i<n.length();i++){
            if((n[i-1] - '0')<((n[i] - '0')-1)){
                int temp=n[i-1] - '0';
                n[i-1]=char((n[i] - '0') - 1) + '0';
                n[i]=char(temp) + '0';
                change++;
            }
        }
    }
    cout<<n<<endl;
}
return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

void solve(string s){
    string str("v");
    long long n = s.size();
    while(str!=s){
        str=s;
        for(long long i=1;i<n;i+=1){
            if(s[n-i]>s[n-i-1]+1){
                s[n-i]=s[n-i]-1;
                swap(s[n-i],s[n-i-1]);
            }
        }
    }
    for(auto i:s){
        cout << i ;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        solve(s);
        cout << endl;
    }
}

Submission (verdict: Time limit exceeded on test 8):
#include <iostream>
#include <string>
using namespace std;

void solve(string s) {
    long long n = s.size();
    bool updated = true;

    while (updated) {
        updated = false;
        for (long long i = n - 1; i > 0; --i) {
            if (s[i] > s[i - 1] + 1) {
                s[i]--;
                swap(s[i], s[i - 1]);
                updated = true;  // Mark as updated to repeat the process
            }
        }
    }

    cout << s;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        solve(s);
        cout << endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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

void solve(string s){
    string str("v");
    long long n = s.size();
    while(str!=s){
        str=s;
        for(long long i=1;i<n;i+=1){
            if(s[n-i]>s[n-i-1]+1){
                s[n-i]=s[n-i]-1;
                swap(s[n-i],s[n-i-1]);
            }
        }
    }
    for(auto i:s){
        cout << i ;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        solve(s);
        cout << endl;
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

#define int long long
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define mii map<int, int>
#define umii unordered_map<int, int>

#define ff first
#define ss second
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define pb push_back
#define all(x) x.begin(),x.end()

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#define pm1 cout << -1 << endl
#define p0 cout << 0 << endl
#define p1 cout << 1 << endl
#define out(x) cout<<x<<endl
#define nl cout<<endl
const int oo = 1e18;
const int mod = 1e9 + 7;

void solve() {
	int n;	cin >> n;
	if (n % 9 == 0)	pyes;
	else {
		int two(0), thr(0);

		int temp = n;
		while (temp) {
			if (temp % 10 == 2)	two++;
			if (temp % 10 == 3)	thr++;
			temp /= 10;
		}

		// cout << two << " " << thr << endl;

		for (int i = 1; i <= two; i++) {
			if ((n + i * 2) % 9 == 0) {
				// out(i + 1);
				pyes;
				return;
			}
			for (int j = 1; j <= thr; j++) {
				if ((n + i * 2 + j * 6) % 9 == 0) {
					// p0;
					pyes;
					return;
				}
			}
		}

		for (int i = 1; i <= thr; i++) {
			if ((n + i * 6) % 9 == 0) {
				// out(i + 1);
				pyes;
				return;
			}
			for (int j = 1; j <= two; j++) {
				if ((n + i * 6 + j * 2) % 9 == 0) {
					// p0;
					pyes;
					return;
				}
			}
		}
		pno;
	}
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	cin >> t;
	// out(t);
	while (t--)	solve();
}

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

#define int long long
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define mii map<int, int>
#define umii unordered_map<int, int>

#define ff first
#define ss second
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define pb push_back
#define all(x) x.begin(),x.end()

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#define pm1 cout << -1 << endl
#define p0 cout << 0 << endl
#define p1 cout << 1 << endl
#define out(x) cout<<x<<endl
#define nl cout<<endl
const int oo = 1e18;
const int mod = 1e9 + 7;

void solve() {
	int n;	cin >> n;
	if (n % 9 == 0)	pyes;
	else {
		int two(0), thr(0);
		int temp = n;
		while (temp) {
			if (temp % 10 == 2)	two++;
			if (temp % 10 == 3)	thr++;
			temp /= 10;
		}

		for (int i = 0; i <= min(10LL, two); i++) {
			if ((n + i * 2) % 9 == 0) {
				// out(i + 1);
				pyes;
				return;
			}
			for (int j = 0; j <= min(10LL, thr); j++) {
				if ((n + i * 2 + j * 6) % 9 == 0) {
					// p0;
					pyes;
					return;
				}
			}
		}
		pno;
	}
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	cin >> t;
	// out(t);
	while (t--)	solve();
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

#define int long long
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define mii map<int, int>
#define umii unordered_map<int, int>

#define ff first
#define ss second
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define pb push_back
#define all(x) x.begin(),x.end()

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#define pm1 cout << -1 << endl
#define p0 cout << 0 << endl
#define p1 cout << 1 << endl
#define out(x) cout<<x<<endl
#define nl cout<<endl
const int oo = 1e18;
const int mod = 1e9 + 7;

void solve() {
	int n;	cin >> n;
	if (n % 9 == 0)	pyes;
	else {
		int two(0), thr(0);
		int temp = n;
		while (temp) {
			if (temp % 10 == 2)	two++;
			if (temp % 10 == 3)	thr++;
			temp /= 10;
		}

		for (int i = 0; i <= min(10LL, two); i++) {
			if ((n + i * 2) % 9 == 0) {
				// out(i + 1);
				pyes;
				return;
			}
			for (int j = 0; j <= min(10LL, thr); j++) {
				if ((n + i * 2 + j * 6) % 9 == 0) {
					// p0;
					pyes;
					return;
				}
			}
		}
		pno;
	}
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	cin >> t;
	// out(t);
	while (t--)	solve();
}

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

#define int long long
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define mii map<int, int>
#define umii unordered_map<int, int>

#define ff first
#define ss second
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define pb push_back
#define aint(x) x.begin(),x.end()

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#define pm1 cout << -1 << endl
#define p0 cout << 0 << endl
#define p1 cout << 1 << endl
#define out(x) cout<<x<<endl
#define nl cout<<endl
const int oo = 1e18;
const int mod = 1e9 + 7;

void solve() {
	string s;	cin >> s;
	int n = s.size(), sum = 0;

	int cnt2 = 0, cnt3 = 0;
	rep(i, n) {
		sum += s[i] - '0';
		if (s[i] - '0' == 2)	cnt2++;
		if (s[i] - '0' == 3)	cnt3++;
	}

	sum %= 9;
	int flag = 0;

	for (int i = 0; i <= min(cnt2, 1int * 20); i++) {
		for (int j = 0; j <= min(cnt3, 1int * 20); j++) {
			int temp = sum;
			temp += i * 2 + j * 6;
			if (temp % 9 == 0) {
				cout << "YES\n";
				return;
			}
		}
	}
	for (int i = 0; i < min(cnt2, 1int * 20); i++) {
		int temp = sum;
		if ((temp + i * 2) % 9 == 0) {
			pyes;
			return;
		}
	}
	for (int i = 0; i < min(cnt3, 1int * 20); i++) {
		int temp = sum;
		if ((temp + i * 3) % 9 == 0) {
			pyes;
			return;
		}
	}
	pno;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	cin >> t;
	// out(t);
	while (t--)	solve();
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

#define int long long
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define mii map<int, int>
#define umii unordered_map<int, int>

#define ff first
#define ss second
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define pb push_back
#define all(x) x.begin(),x.end()

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#define pm1 cout << -1 << endl
#define p0 cout << 0 << endl
#define p1 cout << 1 << endl
#define out(x) cout<<x<<endl
#define nl cout<<endl
const int oo = 1e18;
const int mod = 1e9 + 7;

void solve() {
	int n;	cin >> n;
	if (n % 9 == 0)	pyes;
	else {
		int two(0), thr(0);

		int temp = n;
		while (temp) {
			if (temp % 10 == 2)	two++;
			if (temp % 10 == 3)	thr++;
			temp /= 10;
		}

		// cout << two << " " << thr << endl;

		for (int i = 1; i <= two; i++) {
			if ((n + i * 2) % 9 == 0) {
				// out(i + 1);
				pyes;
				return;
			}
			for (int j = 1; j <= thr; j++) {
				if ((n + i * 2 + j * 6) % 9 == 0) {
					// p0;
					pyes;
					return;
				}
			}
		}

		for (int i = 1; i <= thr; i++) {
			if ((n + i * 6) % 9 == 0) {
				// out(i + 1);
				pyes;
				return;
			}
			for (int j = 1; j <= two; j++) {
				if ((n + i * 6 + j * 2) % 9 == 0) {
					// p0;
					pyes;
					return;
				}
			}
		}
		pno;
	}
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	cin >> t;
	// out(t);
	while (t--)	solve();
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Runtime error on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
      
      int n,m;
      cin>>n>>m;
      vector<int> a(n), b(m);
      for(auto &x:a)cin>>x;
      for(auto &x:b)cin>>x;
      multiset<int> s1,s2;
      priority_queue<int> pq;
      for(auto &x:a)s1.insert(x);
      for(auto &x:b)pq.push(x);
      s2=s1;
      sort(b.rbegin(),b.rend());
      int sum1 = accumulate(a.begin(),a.end(),0);
      int sum2 = accumulate(b.begin(),b.end(),0);
      // cout<<sum1<<" "<<sum2<<endl;
      if(sum1!=sum2){
            // cout<<"lu"<<endl;
            cout<<"No"<<endl;
            return;
      }
      int cnt=0;
      multiset<int> s3;
      while(!pq.empty()){
            if(cnt==n-m+1)break;
            if(s1.empty())break;
            int tp = pq.top();
            // cout<<tp<<endl;
            pq.pop();
            auto it = s1.find(tp);
            if(it!=s1.end()){
                  s1.erase(s1.find(tp));
                  s3.insert(tp);
                  // s2.erase(s2.find(tp));
                  // for(auto &x:s1)cout<<x<<" ";
                  // cout<<endl;
                  continue;
            }
            int f1 = floor(tp/2.0);
            int f2 = tp-f1;
            if(s1.find(f1)==s1.end()||s1.find(f2)==s1.end()){
                  pq.push(f1);
                  pq.push(f2);
                  cnt++;
                  // cout<<cnt<<endl;
                  continue;
            }
            s1.erase(s1.find(f1));
            s1.erase(s1.find(f2));
            s3.insert(f1);
            s3.insert(f2);
      }
      // while(!pq.empty()){
      //       cout<<pq.top()<<endl;
      //       s3.insert(pq.top());
      //       pq.pop();
      // }
      // for(auto &x:s3)cout<<x<<" ";
      // cout<<endl;
      if(s2==s3)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      
      
}

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

      int t;
      cin >> t;

      while (t--) {
            solve();
      }

      return 0;
}
Problem: 2050D - Digital string maximization
Language: PyPy 3


Submission (verdict: Compilation error):
def fun(s):
    for i in range(1, len(s)):
        while i!=0 and s[i]-1 > s[i-1]:
            s[i], s[i-1] = s[i-1], s[i]-1
            i-=1
            
    return ''.join(s)
    
if __name__ == "__main__"":
    for _ in range(int(input())):
        n=list(map(int, input()))
        rs=fun(n)
        print(rs)
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Compilation error):
def fun(s):
    for i in range(1, len(s)):
        while i!=0 and s[i]-1 > s[i-1]:
            s[i], s[i-1] = s[i-1], s[i]-1
            i-=1
            
    return ''.join(s)
    
if __name__ == "__main__"":
    for _ in range(int(input())):
        n=list(map(int, input()))
        rs=fun(n)
        print(rs)

Submission (verdict: Runtime error on test 1):
def fun(s):
    for i in range(1, len(s)):
        while i!=0 and s[i]-1 > s[i-1]:
            s[i], s[i-1] = s[i-1], s[i]-1
            i-=1
            
    return ''.join(s)
    
if __name__ == "__main__":
    for _ in range(int(input())):
        n=list(map(int, input()))
        rs=fun(n)
        print(rs)
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Runtime error on test 1):
def fun(s):
    for i in range(1, len(s)):
        while i!=0 and s[i]-1 > s[i-1]:
            s[i], s[i-1] = s[i-1], s[i]-1
            i-=1
            
    return ''.join(s)
    
if __name__ == "__main__":
    for _ in range(int(input())):
        n=list(map(int, input()))
        rs=fun(n)
        print(rs)

Submission (verdict: Accepted):
def fun(s):
    for i in range(1, len(s)):
        while i!=0 and s[i]-1 > s[i-1]:
            s[i], s[i-1] = s[i-1], s[i]-1
            i-=1
            
    return ''.join(map(str, s))
    
if __name__ == "__main__":
    for _ in range(int(input())):
        n=list(map(int, input()))
        rs=fun(n)
        print(rs)
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
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    ll n;
    cin>>n;
    vll a(n);
    rep(i,0,n) cin>>a[i];

    if(n==1){
        cout<<a[0]<<endl;
        return ;
    }

    ll maxsum = accumulate(a.begin(),a.end(),0);

    ll start = 0, end = start+1;
    
    rep(k,1,n){
        
        ll sumnew = 0;
        while(end < a.size()){
            a[start] = a[end] - a[start];
            start++;
            end = start+1;
        }
        a.pop_back();
        rep(i,0,a.size()){
            sumnew += abs(a[i]);
        }
        maxsum = max(maxsum,sumnew);
        
        start = 0;
        end = start+1;

    }
    cout<<maxsum<<endl;
    return;

}



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

return 0;
}




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

#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    ll n; 
    cin>>n;
    vll v(n); 
    rep(i,0,n) cin>>v[i];

    if(n==1){
        cout<<v[0]<<endl;
        return;
    }

    ll maxsum  = 0;
    rep(i,0,n) maxsum += v[i];
    ll index = n-1;
    

    rep(k,0,n){
        ll sumnew = 0;
        
        rep(j,0,index+1) sumnew += v[j];
        
        maxsum = max(maxsum,abs(sumnew));

        rep(j,0,index) v[j] -= v[j+1];

        index--;
    }
    cout<<maxsum<<endl;
    return;
}

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

return 0;
}
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
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    ll n;
    cin>>n;
    vll a(n);
    rep(i,0,n) cin>>a[i];

    if(n==1){
        cout<<a[0]<<endl;
        return ;
    }

    ll sumin = accumulate(a.begin(),a.end(),0);
    ll sumnew = 0, maxsum = 0;
    ll i = 0, j = i+1;
    
rep(k,1,n){
        vll temp;
        sumnew = 0;
    while(j < a.size()){
        temp.push_back(a[j]-a[i]);
        i++;
        j = i+1;
    }

    rep(i,0,temp.size()){
        a[i] = temp[i];
        sumnew += abs(temp[i]);
    }
    maxsum = max(maxsum,sumnew);
    if(k==n-1) break;
    a.pop_back();
    
    i = 0;
    j = i+1;

}
if(maxsum >= sumin) cout<<maxsum<<endl;
else cout<<sumin<<endl;
return;

}

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

return 0;
}




Submission (verdict: Wrong answer on test 2):



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

#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<long long>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pii pair<int,int>
#define el '\n'
#define value(x) cout<<x<<"\n";

void  solve(){
    ll n;
    cin>>n;
    vll a(n);
    rep(i,0,n) cin>>a[i];

    if(n==1){
        cout<<a[0]<<endl;
        return ;
    }

    ll sumin = accumulate(a.begin(),a.end(),0);
    ll sumnew = 0, maxsum = 0;
    ll start = 0, end = start+1;
    
    rep(k,1,n){
        vll temp;
        sumnew = 0;
        while(end < a.size()){
            temp.push_back(a[end]-a[start]);
            start++;
            end = start+1;
        }

        rep(i,0,temp.size()){
            a[i] = temp[i];
            sumnew += abs(temp[i]);
        }
        maxsum = max(maxsum,sumnew);
        a.pop_back();
        
        start = 0;
        end = start+1;

    }
    if(maxsum >= sumin) cout<<maxsum<<endl;
    else cout<<sumin<<endl;
    return;

}



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

return 0;
}