ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;ll sum=0;
        vector<int>v(n);for(int i=0;i<n;i++) {cin>>v[i];}
        if(n>1 && v[0]<v[n-1]) reverse(v.begin(),v.end());
        for(int i=0;i<n;i++) sum+=v[i];

        while(n>1){
            vector<int>a(n-1);ll sum1=0;
            for(int i=0;i<n-1;i++) {a[i]=v[i+1]-v[i];sum1+=a[i];}
            if(a[0]<a[n-1])reverse(a.begin(),a.end());
            sum=max(sum,sum1);
            v=a;n--;
        }
        cout<<sum<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;ll sum=0;
        vector<ll>v(n);for(int i=0;i<n;i++) {cin>>v[i];}
        if(n>1 && v[0]>v[n-1]) reverse(v.begin(),v.end());
        for(int i=0;i<n;i++) sum+=v[i];
        while(n>1){
            vector<ll>a(n-1);ll sum1=0;
            for(int i=0;i<n-1;i++) {a[i]=v[i+1]-v[i];sum1+=a[i];}
           
            if(a[0]>a[n-1]) reverse(a.begin(),a.end());
            sum=max(sum,sum1);
            v=a;n--;
        }
        cout<<sum<<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;
typedef long long ll;
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;ll sum=0;
        vector<ll>v(n);for(int i=0;i<n;i++) {cin>>v[i];}
        if(n>1 && v[0]>v[n-1]) reverse(v.begin(),v.end());
        for(int i=0;i<n;i++) sum+=v[i];
        while(n>1){
            vector<ll>a(n-1);ll sum1=0;
            for(int i=0;i<n-1;i++) {a[i]=v[i+1]-v[i];sum1+=a[i];}
           
            if(a[0]>a[n-1]) reverse(a.begin(),a.end());
            sum=max(sum,sum1);
            v=a;n--;
        }
        cout<<sum<<endl;
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;ll sum=0;
        vector<ll>v(n);for(int i=0;i<n;i++) {cin>>v[i];}
        if(n>1 && v[0]>v[n-1]) reverse(v.begin(),v.end());
        for(int i=0;i<n;i++) sum+=v[i];
        while(n>1){
            vector<ll>a(n-1);ll sum1=0;
            for(int i=0;i<n-1;i++) {a[i]=v[i+1]-v[i];sum1+=a[i];}
           
            if(a[0]>a[n-2]) reverse(a.begin(),a.end());
            sum=max(sum,sum1);
            v=a;n--;
        }
        cout<<sum<<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;
typedef long long ll;
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;ll sum=0;
        vector<int>v(n);for(int i=0;i<n;i++) {cin>>v[i];sum+=v[i];}
        if(n>1) sum=max(sum,abs(sum));
        while(n>1){
            vector<int>a(n-1);ll sum1=0;
            for(int i=0;i<n-1;i++) {a[i]=v[i+1]-v[i];sum1+=a[i];}
            sum=max(sum,abs(sum1));
            v=a;n--;
        }
        cout<<sum<<endl;
    }
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;ll sum=0;
        vector<int>v(n);for(int i=0;i<n;i++) {cin>>v[i];}
        if(n>1 && v[0]<v[n-1]) reverse(v.begin(),v.end());
        for(int i=0;i<n;i++) sum+=v[i];

        while(n>1){
            vector<int>a(n-1);ll sum1=0;
            for(int i=0;i<n-1;i++) {a[i]=v[i+1]-v[i];sum1+=a[i];}
            if(a[0]<a[n-1])reverse(a.begin(),a.end());
            sum=max(sum,sum1);
            v=a;n--;
        }
        cout<<sum<<endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

#define endl "\n"

#define int long long

using namespace std;

const int N = 2e5 + 10;





int a[N];

void solve(){

    int n; cin >> n;

    int mx = 0, mi = 99999999999; 

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

        cin >> a[i];

        mx = max(mx, a[i]);

        mi = min(mi, a[i]);

    }



    if(mx == a[0] || mi == a[n-1]){

        cout << "NO\n";

    }else{

        cout << "YES\n";

    }

}

signed main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t = 1; cin >> t;

    while(t--)solve();

    return 0;

}

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

#define endl "\n"

#define int long long

using namespace std;

const int N = 2e5 + 10;





int a[N];

void solve(){

    int n; cin >> n;

    int mx = 0;

    cin >> a[0];

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

        cin >> a[i];

        int num = min(a[i], a[i-1]);

        a[i] -= num; a[i-1] -= num;

        mx = max(mx, a[i]);

    }



    if(mx == a[0]){

        cout << "NO\n";

        return;

    }

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

        if(a[i] > a[i+1]){

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

}

signed main(){

    ios::sync_with_stdio(0);

    cin.tie(nullptr);

    int t = 1; cin >> t;

    while(t--)solve();

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

#define endl "\n"

#define int long long

using namespace std;

const int N = 2e5 + 10;





int a[N];

void solve(){

    int n; cin >> n;

    int mx = 0; 

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

        cin >> a[i];

        mx = max(mx, a[i]);

    }



    if(mx == a[0]){

        cout << "NO\n";

    }else{

        cout << "YES\n";

    }

}

signed main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t = 1; cin >> t;

    while(t--)solve();

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

#define endl "\n"

#define int long long

using namespace std;

const int N = 2e5 + 10;





int a[N];

void solve(){

    int n; cin >> n;

    int mx = 0; 

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

        cin >> a[i];

        mx = max(mx, a[i]);

    }



    if(mx == a[0]){

        cout << "NO\n";

    }else{

        cout << "YES\n";

    }

}

signed main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t = 1; cin >> t;

    while(t--)solve();

    return 0;

}

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

#define endl "\n"

#define int long long

using namespace std;

const int N = 2e5 + 10;





int a[N];

void solve(){

    int n; cin >> n;

    int mx = 0, mi = 99999999999; 

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

        cin >> a[i];

        mx = max(mx, a[i]);

        mi = min(mi, a[i]);

    }



    if(mx == a[0] || mi == a[n-1]){

        cout << "NO\n";

    }else{

        cout << "YES\n";

    }

}

signed main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t = 1; cin >> t;

    while(t--)solve();

    return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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



void print(vector<ll>& arr, string s = " "){
for(auto i: arr){cout<<i<<s;}cout<<endl;}
template<typename T>
void print(T n){cout<<n<<endl;}



void solve(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    ll count = 0;
    vector<pair<int,int> > ans;

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            pair<int,int> p1,p2;
            p1.first = a[i];
            p1.second = a[j];
            p2.first = a[j];
            p2.second = a[i];
            if(a[i] < a[j]){
                count+=2;
                ans.push_back(p1);
                ans.push_back(p2);
            }
            else{
                count+=1;
                ans.push_back(p1);
            }
        }
    }

    cout<<count<<endl;
    for(auto i: ans){
        cout<<i.first<<" "<<i.second<<endl;
    }
}

int main(){

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

solve();
return 0;
}

Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long int



void print(vector<ll>& arr, string s = " "){
for(auto i: arr){cout<<i<<s;}cout<<endl;}
template<typename T>
void print(T n){cout<<n<<endl;}



void solve(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    ll count = 0;
    vector<pair<int,int> > ans;

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            pair<int,int> p1,p2;
            p1.first = a[i];
            p1.second = a[j];
            p2.first = a[j];
            p2.second = a[i];
            if(a[i] < a[j]){
                count+=2;
                ans.push_back(p1);
                ans.push_back(p2);
            }
            else{
                count+=1;
                ans.push_back(p1);
            }
        }
    }

    cout<<count<<endl;

    // sort on basis of second element
    sort(ans.begin(),ans.end(),[](pair<int,int> a, pair<int,int> b){
        return a.second < b.second;
    });
    for(auto i: ans){
        cout<<i.first<<" "<<i.second<<endl;
    }
}

int main(){

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

solve();
return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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



void print(vector<ll>& arr, string s = " "){
for(auto i: arr){cout<<i<<s;}cout<<endl;}
template<typename T>
void print(T n){cout<<n<<endl;}



void solve(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    ll count = 0;
    vector<pair<int,int> > ans;

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            pair<int,int> p1,p2;
            p1.first = a[i];
            p1.second = a[j];
            p2.first = a[j];
            p2.second = a[i];
            if(a[i] < a[j]){
                count+=2;
                ans.push_back(p1);
                ans.push_back(p2);
            }
            else{
                count+=1;
                ans.push_back(p1);
            }
        }
    }

    cout<<count<<endl;
    for(auto i: ans){
        cout<<i.first<<" "<<i.second<<endl;
    }
}

int main(){

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

solve();
return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long int



void print(vector<ll>& arr, string s = " "){
for(auto i: arr){cout<<i<<s;}cout<<endl;}
template<typename T>
void print(T n){cout<<n<<endl;}



void solve(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    ll count = 0;
    vector<pair<int,int> > ans;

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            pair<int,int> p1,p2;
            p1.first = a[i];
            p1.second = a[j];
            p2.first = a[j];
            p2.second = a[i];
            if(a[i] < a[j]){
                count+=2;
                ans.push_back(p1);
                ans.push_back(p2);
            }
            else{
                count+=1;
                ans.push_back(p1);
            }
        }
    }

    cout<<count<<endl;

    // sort on basis of second element
    sort(ans.begin(),ans.end(),[](pair<int,int> a, pair<int,int> b){
        return a.second < b.second;
    });
    for(auto i: ans){
        cout<<i.first<<" "<<i.second<<endl;
    }
}

int main(){

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

solve();
return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long int



void print(vector<ll>& arr, string s = " "){
for(auto i: arr){cout<<i<<s;}cout<<endl;}
template<typename T>
void print(T n){cout<<n<<endl;}



void solve(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    ll count = 0;
    vector<pair<int,int> > ans;

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            pair<int,int> p1;
            p1.second = i+1;
            p1.first = j+1;
            ans.push_back(p1);
            count++;
        }
    }
    map<ll, ll> mp;
    vector<ll> b = a;
    sort(b.rbegin(),b.rend());
    for(int i = 0; i < n; i++){
        mp[i+1] = n-i-1;
    }

    int i=0;
    while(i<n-1){
        ll num = a[i];
        int idx = mp[num];
        if (idx == i){
            i++;
            continue;
        }
        while(idx > i){
            pair<int,int> p1;
            p1.first = b[idx];
            p1.second = b[idx-1];
            swap(b[idx],b[idx-1]);
            ans.push_back(p1);
            count++;
            mp[b[idx]] = idx;
            mp[b[idx-1]] = idx-1;
            idx--;
        }
        i++;
    }


    cout<<count<<endl;
    for(int i = 0; i < ans.size(); i++){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }


}

int main(){

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

solve();
return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define rep(i, n)  for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define sum(v) reduce(all(v))
#define pb push_back
#define int long long int
typedef  long double ld;
// 1e7 1e9+7 1e18

int range_sum(int l,int r) {
    if (l > r) return 0;
    return (l + r) * (r - l + 1) / 2;
}
void pv(vector<int> nums) {
    for(auto e: nums) cout << e<<" ";
    cout <<"\n";
}
vector<string> split(const string& str, char delimiter) {
    vector<string> tokens;
    string token;
    istringstream stream(str);
    while (getline(stream, token, delimiter)) {
        tokens.push_back(token);
    }
    return tokens;
}

// Helper function for single argument
template <typename T>
std::string to_string(const T& t) {
    std::ostringstream oss;
    oss << t;
    return oss.str();
}

// Variadic template for multiple arguments
template <typename T, typename... Args>
std::string to_string(const T& first, const Args&... rest) {
    return to_string(first) + ", " + to_string(rest...);
}

// Macro for easy usage
#define print(...) (std::cout << to_string(__VA_ARGS__) << std::endl)


void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    map<int,int> ogpos;
    rep(i,n) ogpos[a[i]] = i;

    vector<vector<int>> count(n+1, vector<int>(n+1,0));
    //bubble
    //pv(a);
    vector<pair<int,int>> otks;
    for(int i = 0; i<n; i++) {
        for(int j = 0; j<n-1; j++) {
            if(a[j]>a[j+1]) {
                count[a[j+1]][a[j]]++;
                otks.push_back({a[j+1],a[j]});
                swap(a[j],a[j+1]);
            }
        }
    }
    //pv(a);
    for(const auto x: a) {
        for(const auto y: a) {
            if(x>=y) continue; // x<y guaranteed
            if(count[x][y]  == 0) {
                //print(x,y);
                otks.push_back({x,y});
                otks.push_back({y,x});
            }
        }
    }
    print(otks.size());
    for(auto p: otks) {
        cout<< p.first<< " " <<p.second <<"\n";
    }
}
 
int32_t main() {
    fast;
    solve();
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Memory limit exceeded on test 4):
#include <bits/stdc++.h>



#define ll long long

#define mod 1000000007

#define INF 1e9



using namespace std;



void input1(vector<ll>& num, ll n){

	for(int i = 0 ; i < n ; ++i) cin >> num[i];

}



void input2(vector<vector<ll> >& num, int n, int m) {

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

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

            cin >> num[i][j];

        }

    }

}



void solve() {

	string s;

	cin >> s;

	int dem2 = 0;

	int dem3 = 0;

	ll tong = 0;

	vector<int> num(s.length());

	for(int i=0;i<s.length();++i){

		num[i] = s[i]-'0';

		if(num[i]!=2&&num[i]!=3){

			tong+=num[i];

		}else if(num[i]==2){

			++dem2;

		}else if(num[i]==3){

			++dem3;

		}

	}

	ll tong2 = 2*dem2;

	ll tong3 = 3*dem3; 

	vector<vector<ll>> dp(dem2+2,vector<ll> (dem3+2));

	dp[0][0] = 0;

	for(int i=0;i<=dem2+1;++i){

		for(int j=0;j<=dem3+1;++j){

			if(i==0&&j!=0){

				dp[i][j] = tong3+6*(j-1);

			}else if(j==0&&i!=0){

				dp[i][j] = tong2+2*(i-1);

			}else if(i!=0&&j!=0){

				dp[i][j] = dp[0][j]+dp[i][0];

			}

		}

	}

	/*

	for(int i=0;i<=dem2+1;++i){

		for(int j=0;j<=dem3+1;++j){

			cout << dp[i][j] << " ";

		}

		cout << endl;

	}

	*/

	string ans = "NO";

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

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

			ll w = tong+dp[i][j];

			if(w%9==0){

				ans = "YES";

				//break;

			}

			//cout << w << " ";

		}

		//cout << endl;

		if(ans=="YES"){

			//break;

		}

	}

	cout << ans << endl;

}



int main() {

	ios::sync_with_stdio(false);

	int tt; cin >> tt; for (int i = 0; i < tt; i++) {solve();}

	//solve();

}



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



#define ll long long

#define mod 1000000007

#define INF 1e9



using namespace std;



void input1(vector<ll>& num, ll n){

	for(int i = 0 ; i < n ; ++i) cin >> num[i];

}



void input2(vector<vector<ll> >& num, int n, int m) {

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

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

            cin >> num[i][j];

        }

    }

}



void solve() {

	string s;

	cin >> s;

	int dem2 = 0;

	int dem3 = 0;

	ll tong = 0;

	vector<int> num(s.length());

	for(int i=0;i<s.length();++i){

		num[i] = s[i]-'0';

		if(num[i]!=2&&num[i]!=3){

			tong+=num[i];

		}else if(num[i]==2){

			++dem2;

		}else if(num[i]==3){

			++dem3;

		}

	} 

	vector<ll> hai(dem2+1);

	vector<ll> ba(dem3+1);

	hai[0] = 2*dem2;

	ba[0] = 3*dem3;

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

		hai[i] = hai[0]+2*i;

	}

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

		ba[i] = ba[0]+6*i;

	}

	string ans = "NO";

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

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

			ll w = hai[i]+ba[j]+tong;

			if(w%9==0){

				ans = "YES";

				break;

			}

		}

		if(ans=="YES"){

			break;

		}

	}

	cout << ans << endl;

}



int main() {

	ios::sync_with_stdio(false);

	int tt; cin >> tt; for (int i = 0; i < tt; i++) {solve();}

	//solve();

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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



#define ll long long

#define mod 1000000007

#define INF 1e9



using namespace std;



void input1(vector<ll>& num, ll n){

	for(int i = 0 ; i < n ; ++i) cin >> num[i];

}



void input2(vector<vector<ll> >& num, int n, int m) {

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

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

            cin >> num[i][j];

        }

    }

}



void solve() {

	string s;

	cin >> s;

	int dem2 = 0;

	int dem3 = 0;

	ll tong = 0;

	vector<int> num(s.length());

	for(int i=0;i<s.length();++i){

		num[i] = s[i]-'0';

		if(num[i]!=2&&num[i]!=3){

			tong+=num[i];

		}else if(num[i]==2){

			++dem2;

		}else if(num[i]==3){

			++dem3;

		}

	}

	if(dem2==0&&dem3!=0){

		cout << "YES" << endl;

		return;

	}else if(dem2!=0&&dem3==0){

		if(dem2%9==0){

			cout << "YES" << endl;

		}else{

			cout << "NO" << endl;

		}

		return;

	}

	ll tong2 = 2*dem2;

	ll tong3 = 3*dem3; 

	vector<vector<ll>> dp(dem2+2,vector<ll> (dem3+2));

	dp[0][0] = 0;

	for(int i=0;i<=dem2+1;++i){

		for(int j=0;j<=dem3+1;++j){

			if(i==0&&j!=0){

				dp[i][j] = tong3+6*(j-1);

			}else if(j==0&&i!=0){

				dp[i][j] = tong2+2*(i-1);

			}else if(i!=0&&j!=0){

				dp[i][j] = dp[0][j]+dp[i][0];

			}

		}

	}

	/*

	for(int i=0;i<=dem2+1;++i){

		for(int j=0;j<=dem3+1;++j){

			cout << dp[i][j] << " ";

		}

		cout << endl;

	}

	*/

	string ans = "NO";

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

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

			ll w = tong+dp[i][j];

			if(w%9==0){

				ans = "YES";

				//break;

			}

			//cout << w << " ";

		}

		//cout << endl;

		if(ans=="YES"){

			//break;

		}

	}

	cout << ans << endl;

}



int main() {

	ios::sync_with_stdio(false);

	int tt; cin >> tt; for (int i = 0; i < tt; i++) {solve();}

	//solve();

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn];
int main(){
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		for(int i = 0; i < n; i++)
			cin >> a[i];
			
		int ind = 0;
		bool flag = 0;
		while(ind != n - 2){
			if(a[ind] > a[ind+1]){
				flag = 1;
				break;
			}
			a[ind+1] -= a[ind];
			a[ind] = 0;
			ind += 1;
		}
		if(flag)
			cout << "NO\n";
		else
			cout << "YES\n";
		
	
	}
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn];
int main(){
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		for(int i = 0; i < n; i++)
			cin >> a[i];
			
		int ind = 0;
		bool flag = 0;
		if(n == 2 && a[0] > a[1]){
			cout << "NO\n";
			continue;
		}
		while(ind != n - 2){
			if(a[ind] > a[ind+1]){
				flag = 1;
				break;
			}
			a[ind+1] -= a[ind];
			a[ind] = 0;
			ind += 1;
		}
		if(flag)
			cout << "NO\n";
		else
			cout << "YES\n";
		
	
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn];
int main(){
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		for(int i = 0; i < n; i++)
			cin >> a[i];
			
		int ind = 0;
		bool flag = 0;
		while(ind != n - 2){
			if(a[ind] > a[ind+1]){
				flag = 1;
				break;
			}
			a[ind+1] -= a[ind];
			a[ind] = 0;
			ind += 1;
		}
		if(flag)
			cout << "NO\n";
		else
			cout << "YES\n";
		
	
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn];
int main(){
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		for(int i = 0; i < n; i++)
			cin >> a[i];
			
		int ind = 0;
		bool flag = 0;
		if(n == 2 && a[0] > a[1]){
			cout << "NO\n";
			continue;
		}
		while(ind != n - 2){
			if(a[ind] > a[ind+1]){
				flag = 1;
				break;
			}
			a[ind+1] -= a[ind];
			a[ind] = 0;
			ind += 1;
		}
		if(flag)
			cout << "NO\n";
		else
			cout << "YES\n";
		
	
	}
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn];
int main(){
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		for(int i = 0; i < n; i++)
			cin >> a[i];
			
		int ind = 0;
		bool flag = 0;
//		if(n == 2 && a[0] > a[1]){
//			cout << "NO\n";
//			continue;
//		}
		while(ind <= n - 2){
			if(a[ind] > a[ind+1]){
				flag = 1;
				break;
			}
			a[ind+1] -= a[ind];
			a[ind] = 0;
			ind += 1;
		}
		if(flag)
			cout << "NO\n";
		else
			cout << "YES\n";
		
	
	}
}