ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <cmath>
using ll = long long;
#define forn(start, finish) for (ll i = (start); i < ll(finish); ++i)
#define en '\n'

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vector<ll> a(n);
		forn(0, n) cin >> a[i];
		ll i = 1;
		bool bad = false;
		ll next = a[1] - a[0];
		forn(2, n - 1) {
			if (next < 0) {
				bad = true;
				break;
			}
			if (a[i]>=next) {
				next = a[i] - next;
			}
			else {
				bad = true;
				break;
			}
		}
		if (bad) cout << "NO\n";
		else cout << "YES\n";
	}
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <cmath>
using ll = long long;
#define forn(start, finish) for (ll i = (start); i < ll(finish); ++i)
#define en '\n'

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vector<ll> a(n);
		forn(0, n) cin >> a[i];
		ll i = 1;
		bool bad = false;
		ll next = a[1] - a[0];
		forn(2, n) {
			if (next < 0) {
				bad = true;
				break;
			}
			if (a[i]>=next) {
				next = a[i] - next;
			}
			else {
				bad = true;
				break;
			}
		}
		if (bad) cout << "NO\n";
		else cout << "YES\n";
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <cmath>
using ll = long long;
#define forn(start, finish) for (ll i = (start); i < ll(finish); ++i)
#define en '\n'

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vector<ll> a(n);
		forn(0, n) cin >> a[i];
		ll i = 1;
		bool bad = false;
		ll next = a[1] - a[0];
		forn(2, n) {
			if (next < 0) {
				bad = true;
				break;
			}
			if (a[i]>=next) {
				next = a[i] - next;
			}
			else {
				bad = true;
				break;
			}
		}
		if (bad) cout << "NO\n";
		else cout << "YES\n";
	}
}

Submission (verdict: Accepted):
#include<iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <cmath>
using ll = long long;
#define forn(start, finish) for (ll i = (start); i < ll(finish); ++i)
#define en '\n'

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vector<ll> a(n);
		forn(0, n) cin >> a[i];
		ll i = 1;
		bool bad = false;
		ll next = a[1] - a[0];
		forn(2, n) {
			if (next < 0) {
				bad = true;
				break;
			}
			if (a[i]>=next) {
				next = a[i] - next;
			}
			else {
				bad = true;
				break;
			}
		}
		if (bad || next<0) cout << "NO\n";
		else cout << "YES\n";
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <cmath>
using ll = long long;
#define forn(start, finish) for (ll i = (start); i < ll(finish); ++i)
#define en '\n'

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vector<ll> a(n);
		forn(0, n) cin >> a[i];
		ll i = 1;
		bool bad = false;
		ll next = a[1] - a[0];
		forn(2, n - 1) {
			if (next < 0) {
				bad = true;
				break;
			}
			if (a[i]>=next) {
				next = a[i] - next;
			}
			else {
				bad = true;
				break;
			}
		}
		if (bad) cout << "NO\n";
		else cout << "YES\n";
	}
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll ;

const int N = 2e5+103 ;



void solve(){

    ll n , l , r , sum = 0 ;

    cin >> n >> l >> r ;

    vector <ll> a(n+1) ;

    priority_queue <ll> q , q2;

    priority_queue <ll , vector<ll> , greater<int>> ql, qr ;

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

        cin >> a[i] ;

        if(i >= l && i <= r)

            q.push(a[i]) , sum += a[i] , q2.push(a[i]) ;

        else if(i < l)

            ql.push(a[i]) ;

        else    

            qr.push(a[i]) ;

    }

    ll tmp = sum , ans = 1e15 ;

    while(!q.empty() && !ql.empty()){

        ll x = q.top() , y = ql.top() ;

        q.pop() , ql.pop() ;

        if(x >= y){

            sum -= x ;

            sum += y ;

        }else{

            break ;

        }

    } 

    ans = min(ans , sum) ;

    sum = tmp ;

    while(!q2.empty() && !qr.empty()){

        ll x = q.top() , y = qr.top() ;

        q.pop() , qr.pop() ;

        if(x >= y){

            sum -= x ;

            sum += y ;

        }else{

            break ;

        }

    }

    ans = min(ans , sum) ;

    cout << ans << '\n' ;

}



int main(){

    ios_base::sync_with_stdio(false);

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



    int t ;

    cin >> t ;



    while(t--)

        solve();



    return 0 ;

}



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

using namespace std;

typedef long long ll ;

const int N = 2e5+103 ;



void solve(){

    ll n , l , r , sum = 0 ;

    cin >> n >> l >> r ;

    vector <ll> a(n+1) ;

    priority_queue <ll> q , q2;

    priority_queue <ll , vector<ll> , greater<ll>> ql, qr ;

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

        cin >> a[i] ;

        if(i >= l && i <= r)

            q.push(a[i]) , sum += a[i] , q2.push(a[i]) ;

        else if(i < l)

            ql.push(a[i]) ;

        else    

            qr.push(a[i]) ;

    }

    ll tmp = sum , ans = 1e15 ;

    while(!q.empty() && !ql.empty()){

        ll x = q.top() , y = ql.top() ;

        q.pop() , ql.pop() ;

        if(x >= y){

            sum -= x ;

            sum += y ;

        }else{

            break ;

        }

    } 

    ans = min(ans , sum) ;

    sum = tmp ;

    while(!q2.empty() && !qr.empty()){

        ll x = q.top() , y = qr.top() ;

        q.pop() , qr.pop() ;

        if(x >= y){

            sum -= x ;

            sum += y ;

        }else{

            break ;

        }

    }

    ans = min(ans , sum) ;

    cout << ans << '\n' ;

}



int main(){

    ios_base::sync_with_stdio(false);

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



    int t ;

    cin >> t ;



    while(t--)

        solve();



    return 0 ;

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


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

using namespace std;

typedef long long ll ;

const int N = 2e5+103 ;



void solve(){

    ll n , l , r , sum = 0 ;

    cin >> n >> l >> r ;

    vector <ll> a(n+1) ;

    priority_queue <ll> q , q2;

    priority_queue <ll , vector<ll> , greater<int>> ql, qr ;

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

        cin >> a[i] ;

        if(i >= l && i <= r)

            q.push(a[i]) , sum += a[i] , q2.push(a[i]) ;

        else if(i < l)

            ql.push(a[i]) ;

        else    

            qr.push(a[i]) ;

    }

    ll tmp = sum , ans = 1e15 ;

    while(!q.empty() && !ql.empty()){

        ll x = q.top() , y = ql.top() ;

        q.pop() , ql.pop() ;

        if(x >= y){

            sum -= x ;

            sum += y ;

        }else{

            break ;

        }

    } 

    ans = min(ans , sum) ;

    sum = tmp ;

    while(!q2.empty() && !qr.empty()){

        ll x = q.top() , y = qr.top() ;

        q.pop() , qr.pop() ;

        if(x >= y){

            sum -= x ;

            sum += y ;

        }else{

            break ;

        }

    }

    ans = min(ans , sum) ;

    cout << ans << '\n' ;

}



int main(){

    ios_base::sync_with_stdio(false);

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



    int t ;

    cin >> t ;



    while(t--)

        solve();



    return 0 ;

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

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

using namespace std;

typedef long long ll ;

const int N = 2e5+103 ;



void solve(){

    ll n , l , r , sum = 0 ;

    cin >> n >> l >> r ;

    vector <ll> a(n+1) ;

    priority_queue <ll> q , q2;

    priority_queue <ll , vector<ll> , greater<ll>> ql, qr ;

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

        cin >> a[i] ;

        if(i >= l && i <= r)

            q.push(a[i]) , sum += a[i] , q2.push(a[i]) ;

        else if(i < l)

            ql.push(a[i]) ;

        else    

            qr.push(a[i]) ;

    }

    ll tmp = sum , ans = 1e15 ;

    while(!q.empty() && !ql.empty()){

        ll x = q.top() , y = ql.top() ;

        q.pop() , ql.pop() ;

        if(x >= y){

            sum -= x ;

            sum += y ;

        }else{

            break ;

        }

    } 

    ans = min(ans , sum) ;

    sum = tmp ;

    while(!q2.empty() && !qr.empty()){

        ll x = q.top() , y = qr.top() ;

        q.pop() , qr.pop() ;

        if(x >= y){

            sum -= x ;

            sum += y ;

        }else{

            break ;

        }

    }

    ans = min(ans , sum) ;

    cout << ans << '\n' ;

}



int main(){

    ios_base::sync_with_stdio(false);

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



    int t ;

    cin >> t ;



    while(t--)

        solve();



    return 0 ;

}



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

using namespace std;

typedef long long ll ;

const int N = 2e5+103 ;



void solve(){

    ll n , l , r , ans1 = 0 , ans2 = 0 ;

    cin >> n >> l >> r ;

    vector <ll> a(n) , b(n) ;

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

        cin >> a[i] ;

        b[i] = a[i] ;

    }

    sort(a.begin() , a.begin()+r) ;

    sort(b.begin()+l-1 , b.end()) ;

    int len = r-l+1 ;

    for(int i = 0 ; i < r && i < len ; i ++){

        ans1 += a[i] ;

    }

    for(int i = l-1 , cnt = 0; i < n && cnt < len ; i++){

        ans2 += b[i] ;

        cnt++ ;

    }

    cout << min(ans1, ans2) << '\n' ;

}



int main(){

    ios_base::sync_with_stdio(false);

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



    int t ;

    cin >> t ;



    while(t--)

        solve();



    return 0 ;

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using str = string;
#define vec vector
#define arr array
#define all(x) x.begin(), x.end()
#define p(x) cout << (x) << endl
#define pv(x) for(auto& _:x){cout<<(_)<<' ';}cout<<endl;

#ifdef LOCAL
#include "debug.cpp"
#else
#define d(x) 69
#endif

void solve() {
	int l,r; cin>>l>>r;
	bitset<32> a(l), b(l), diff(l^r);
	int i=29;
	while(diff[i]!=1 and i>=0) i--;
	a[i]=0; b[i]=1;
	for(int j=i-1; j>=0; j--){
		a[i]=1; b[i]=0;
	}
	int aa = a.to_ulong();
	int bb = b.to_ulong();
	int c=l;
	if(c==aa || c==bb) c++;
	vec<int> out = {aa,bb,c};	
	pv(out);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t; cin>>t; while(t--)solve();
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using str = string;
#define vec vector
#define arr array
#define all(x) x.begin(), x.end()
#define p(x) cout << (x) << endl
#define pv(x) for(auto& _:x){cout<<(_)<<' ';}cout<<endl;

#ifdef LOCAL
#include "debug.cpp"
#else
#define d(x) 69
#endif

void solve() {
	int l,r; cin>>l>>r;
	bitset<32> a(l), b(l), diff(l^r);
	int i=29;
	while(diff[i]!=1 and i>=0) i--;
	a[i]=0; b[i]=1;
	for(int j=i-1; j>=0; j--){
		a[i]=1; b[i]=0;
	}
	int aa = a.to_ulong();
	int bb = b.to_ulong();
	int c=l;
	if(c==aa || c==bb) c++;
	vec<int> out = {aa,bb,c};	
	pv(out);
}

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


Submission (verdict: Wrong answer on test 1):
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using str = string;
#define vec vector
#define arr array
#define all(x) x.begin(), x.end()
#define p(x) cout << (x) << endl
#define pv(x) for(auto& _:x){cout<<(_)<<' ';}cout<<endl;

#ifdef LOCAL
#include "debug.cpp"
#else
#define d(x) 69
#endif

void solve() {
	int l,r; cin>>l>>r;
	bitset<32> a(l), b(l), diff(l^r);
	int i=29;
	while(diff[i]!=1 and i>=0) i--;
	a[i]=0; b[i]=1;
	for(int j=i-1; j>=0; j--){
		a[j]=1; b[j]=0;
	}
	int aa = a.to_ulong();
	int bb = b.to_ulong();
	int c=l;
	if(c==aa || c==bb) c++;
	vec<int> out = {aa,bb,c};	
	pv(out);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t; cin>>t; while(t--)solve();
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using str = string;
#define vec vector
#define arr array
#define all(x) x.begin(), x.end()
#define p(x) cout << (x) << endl
#define pv(x) for(auto& _:x){cout<<(_)<<' ';}cout<<endl;

#ifdef LOCAL
#include "debug.cpp"
#else
#define d(x) 69
#endif

void solve() {
	int l,r; cin>>l>>r;
	bitset<32> a(l), b(l), diff(l^r);
	int i=29;
	while(diff[i]!=1 and i>=0) i--;
	a[i]=0; b[i]=1;
	for(int j=i-1; j>=0; j--){
		a[j]=1; b[j]=0;
	}
	int aa = a.to_ulong();
	int bb = b.to_ulong();
	int c=l;
	if(c==aa || c==bb) c++;
	vec<int> out = {aa,bb,c};	
	pv(out);
}

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


Submission (verdict: Accepted):
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using str = string;
#define vec vector
#define arr array
#define all(x) x.begin(), x.end()
#define p(x) cout << (x) << endl
#define pv(x) for(auto& _:x){cout<<(_)<<' ';}cout<<endl;

#ifdef LOCAL
#include "debug.cpp"
#else
#define d(x) 69
#endif

void solve() {
	int l,r; cin>>l>>r;
	bitset<32> a(l), b(l), diff(l^r);
	int i=29;
	while(diff[i]!=1 and i>=0) i--;
	a[i]=0; b[i]=1;
	for(int j=i-1; j>=0; j--){
		a[j]=1; b[j]=0;
	}
	int aa = a.to_ulong(); d(aa);
	int bb = b.to_ulong(); d(bb);
	int c=l;
	while(c==aa or c==bb) c++;
	d(c);
	vec<int> out = {aa,bb,c};	
	pv(out);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t; cin>>t; while(t--)solve();
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	int t;

	cin >> t;

	while (t--) {

		string n;

		cin >> n;

		long long cnt = 0;

		long long cnt2 = 0;

		long long cnt3 = 0;

		for (int i = 0; i < n.size(); i++) {

			cnt += n[i] - '0';

			if (n[i] == '2') {

				cnt2++;

			}

			else if (n[i] == '3') {

				cnt3++;

			}

		}

		if (cnt % 9 == 0) {

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

			continue;

		}

		int flag = 0;

		for (int i = 0; i <= cnt2; i++) {

			for (int j = 0; j <= cnt3; j++) {

				long long cnt1 = cnt + 2 * i + 6 * j;

				if (cnt1 % 9 == 0) {

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

					flag = 1;

					break;

				}

			}

		}

		if (!flag) {

			cout << "NO" << "\n";

		}

	}

}

Submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	int t;

	cin >> t;

	while (t--) {

		string n;

		cin >> n;

		long long cnt = 0;

		long long cnt2 = 0;

		long long cnt3 = 0;

		for (int i = 0; i < n.size(); i++) {

			cnt += n[i] - '0';

			if (n[i] == '2') {

				cnt2++;

			}

			else if (n[i] == '3') {

				cnt3++;

			}

		}

		int flag = 0;

		for (int i = 0; i <= cnt2; i++) {

			for (int j = 0; j <= cnt3; j++) {

				unsigned long long cnt1 = cnt + 2 * i + 6 * j;

				if (cnt1 % 9 == 0) {

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

					flag = 1;

					break;

				}

			}

		}

		if (!flag) {

			cout << "NO" << "\n";

		}

	}

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


Submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	int t;

	cin >> t;

	while (t--) {

		string n;

		cin >> n;

		long long cnt = 0;

		long long cnt2 = 0;

		long long cnt3 = 0;

		for (int i = 0; i < n.size(); i++) {

			cnt += n[i] - '0';

			if (n[i] == '2') {

				cnt2++;

			}

			else if (n[i] == '3') {

				cnt3++;

			}

		}

		if (cnt % 9 == 0) {

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

			continue;

		}

		int flag = 0;

		for (int i = 0; i <= cnt2; i++) {

			for (int j = 0; j <= cnt3; j++) {

				long long cnt1 = cnt + 2 * i + 6 * j;

				if (cnt1 % 9 == 0) {

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

					flag = 1;

					break;

				}

			}

		}

		if (!flag) {

			cout << "NO" << "\n";

		}

	}

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

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	int t;

	cin >> t;

	while (t--) {

		string n;

		cin >> n;

		long long cnt = 0;

		long long cnt2 = 0;

		long long cnt3 = 0;

		for (int i = 0; i < n.size(); i++) {

			cnt += n[i] - '0';

			if (n[i] == '2') {

				cnt2++;

			}

			else if (n[i] == '3') {

				cnt3++;

			}

		}

		int flag = 0;

		for (int i = 0; i <= cnt2; i++) {

			for (int j = 0; j <= cnt3; j++) {

				unsigned long long cnt1 = cnt + 2 * i + 6 * j;

				if (cnt1 % 9 == 0) {

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

					flag = 1;

					break;

				}

			}

		}

		if (!flag) {

			cout << "NO" << "\n";

		}

	}

}

Submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	int t;

	cin >> t;

	while (t--) {

		string n;

		cin >> n;

		long long cnt = 0;

		long long cnt2 = 0;

		long long cnt3 = 0;

		for (int i = 0; i < n.size(); i++) {

			cnt += n[i] - '0';

			if (n[i] == '2') {

				cnt2++;

			}

			else if (n[i] == '3') {

				cnt3++;

			}

		}

		int c = cnt % 9;

		if (cnt % 9 == 0) {

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

			continue;

		}

		vector<int> a;

		vector<int> b;

		a.push_back(0);

		b.push_back(0);

		int flag = 0;

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

			flag += 2;

			flag %= 9;

			a.push_back(flag);

		}

		flag = 0;

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

			flag += 6;

			flag %= 9;

			b.push_back(flag);

		}

		flag = 0;

		for (auto p : a) {

			for (auto q : b) {

				if ((q + p) % 9 == 9 - c) {

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

					flag = 1;

					break;

				}

			}

		}

		if (!flag) {

			cout << "NO" << "\n";

		}

	}

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

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	int t;

	cin >> t;

	while (t--) {

		string n;

		cin >> n;

		long long cnt = 0;

		long long cnt2 = 0;

		long long cnt3 = 0;

		for (int i = 0; i < n.size(); i++) {

			cnt += n[i] - '0';

			if (n[i] == '2') {

				cnt2++;

			}

			else if (n[i] == '3') {

				cnt3++;

			}

		}

		int c = cnt % 9;

		if (cnt % 9 == 0) {

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

			continue;

		}

		vector<int> a;

		vector<int> b;

		a.push_back(0);

		b.push_back(0);

		int flag = 0;

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

			flag += 2;

			flag %= 9;

			a.push_back(flag);

		}

		flag = 0;

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

			flag += 6;

			flag %= 9;

			b.push_back(flag);

		}

		flag = 0;

		for (auto p : a) {

			for (auto q : b) {

				if ((q + p) % 9 == 9 - c) {

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

					flag = 1;

					break;

				}

			}

		}

		if (!flag) {

			cout << "NO" << "\n";

		}

	}

}

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

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	int t;

	cin >> t;

	while (t--) {

		string n;

		cin >> n;

		long long cnt = 0;

		long long cnt2 = 0;

		long long cnt3 = 0;

		for (int i = 0; i < n.size(); i++) {

			cnt += n[i] - '0';

			if (n[i] == '2') {

				cnt2++;

			}

			else if (n[i] == '3') {

				cnt3++;

			}

		}

		int c = cnt % 9;

		if (cnt % 9 == 0) {

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

			continue;

		}

		vector<int> a;

		vector<int> b;

		a.push_back(0);

		b.push_back(0);

		int flag = 0;

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

			flag += 2;

			flag %= 9;

			a.push_back(flag);

		}

		flag = 0;

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

			flag += 6;

			flag %= 9;

			b.push_back(flag);

		}

		flag = 0;

		for (auto p : a) {

			for (auto q : b) {

				if ((q + p) % 9 == 9 - c) {

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

					flag = 1;

					break;

				}

			}

			if (flag) {

				break;

			}

		}

		if (!flag) {

			cout << "NO" << "\n";

		}

	}

}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		if (n == 1) {
			cout << a[0] << "\n";
			continue;
		}
		long long ans = 0;
		for (int i = 0; i < n - 1; i++) {
			ans = accumulate(a.begin(), a.end(), 0LL);
			if (a[0] < a.back()) {
				reverse(a.begin(), a.end());
			}
			long long sum = 0;
			for (int i = 0; i < a.size()-1; i++) {
				a[i] = a[i] - a[i + 1];
				sum += a[i];
			}
			ans = max(ans, sum);
			a.pop_back();
		}
		cout << ans << "\n";
	}
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		if (n == 1) {
			cout << a[0] << "\n";
			continue;
		}
		long long ans = 0;
		ans = accumulate(a.begin(), a.end(), 0LL);
		for (int i = 0; i < n - 1; i++) {
			long long x = accumulate(a.begin(), a.end(), 0LL);
			if (a[0] < a.back()) {
				reverse(a.begin(), a.end());
			}
			long long sum = 0;
			for (int i = 0; i < a.size()-1; i++) {
				a[i] = a[i] - a[i + 1];
				sum += a[i];
			}
			ans = max(ans, max(x,sum));
			a.pop_back();
		}
		cout << ans << "\n";
	}
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		long long ans = 0;
		for (int i = 0; i < n - 1; i++) {
			ans = accumulate(a.begin(), a.end(), 0LL);
			if (a[0] < a.back()) {
				reverse(a.begin(), a.end());
			}
			long long sum = 0;
			for (int i = 0; i < a.size()-1; i++) {
				a[i] = a[i] - a[i + 1];
				sum += a[i];
			}
			ans = max(ans, sum);
			a.pop_back();
		}
		cout << ans << "\n";
	}
}

Submission (verdict: Wrong answer on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		if (n == 1) {
			cout << a[0] << "\n";
			continue;
		}
		long long ans = 0;
		for (int i = 0; i < n - 1; i++) {
			ans = accumulate(a.begin(), a.end(), 0LL);
			if (a[0] < a.back()) {
				reverse(a.begin(), a.end());
			}
			long long sum = 0;
			for (int i = 0; i < a.size()-1; i++) {
				a[i] = a[i] - a[i + 1];
				sum += a[i];
			}
			ans = max(ans, sum);
			a.pop_back();
		}
		cout << ans << "\n";
	}
}