ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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


int32_t main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    reverse(v.begin(),v.end());
    vector<pair<int,int>>ans;
    // x and y 
    
    for(int i=0;i<n;i++){
        
        // x ///i+1 greater means  x is ahead of those 
        // lesser means x is back now cross
        // x v[i+1]<x;
        
        // i-1
        // smaller values already ahead now don't cross; now cross;
        // larger values behind  it's crossed before ..now it's your turn to cross
        // x v[i-1]>x
        for(int j=0;j<i;j++){
            ans.push_back({v[i],v[j]});
        }
        for(int j=i+1;j<n;j++){
            // if v[j]<v[i]  already v[j]
            // if v[i]<v[j] its already ahead 
            if(v[i]>v[j]){
                ans.push_back({v[i],v[j]});
            }
        }
        
    }
    cout<<ans.size()<<"\n";
    for(auto i:ans){
        cout<<i.first<<" "<<i.second<<"\n";
    }
    
}

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


int32_t main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    reverse(v.begin(),v.end());
    vector<pair<int,int>>ans;
    // x and y 
    
    for(int i=0;i<n;i++){
        
        // x ///i+1 greater means  x is ahead of those 
        // lesser means x is back now cross
        // x v[i+1]<x;
        
        // i-1
        // smaller values already ahead now don't cross; now cross;
        // larger values behind  it's crossed before ..now it's your turn to cross
        // x v[i-1]>x
        
        //v[i] can cross all the cars ahead
        // all cars ahead value is always less than v[i] value 
        vector<int>ano;
        for(int j=i+1;j<n;j++){
            // if v[j]<v[i]  already v[j]
            // if v[i]<v[j] its already ahead 
            if(v[i]>v[j]){
                ano.push_back(v[j]);
                
            }
        }
        sort(ano.rbegin(),ano.rend());
        for(auto j:ano){
            ans.push_back({v[i],j});
        }
        for(int j=0;j<i;j++){
            ans.push_back({v[i],v[j]});
        }
        
    }
    cout<<ans.size()<<"\n";
    for(auto i:ans){
        cout<<i.first<<" "<<i.second<<"\n";
    }
    
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define ln '\n'
#define ull unsigned  long long
#define ll long long 
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int> 
#define ld long double
#define ss second
using namespace std;


void setIO(const string io="a"){
    freopen((io+".in").c_str(),"r",stdin) ;
    freopen((io+".out").c_str(),"w",stdout) ;
}


void solve(){
	ll l , r ; cin >> l >> r ;
	ll n = log2(r)+1 ; 
	string s1('0',n) ; 
	ll a = r , i = n-1 ;
	while(a){
		if ((a&1ll)) s1[i--] = '1' ;
		a>>= 1ll ;
	}
	ll b = r-1 ; i = n-1 ;
	string s2('0',n) ; 
	while(b) {
		if ((b&1ll)) s2[i--] = '1' ;
		b >>= 1ll ;
	}
	string s3('0',n) ; 
	ll pow = n-1 , val = 0 ; 
	for(ll i=0;i<n;i++){
		if (val+(1<<pow)-1 < l or  s1[i]=='0' or s2[i]=='0' ) s3[i] = '1' , val += (1ll<<pow) ;
		pow-- ; 
	}
	// ll val = 0 , pow = n-1 ; 
	// for(ll i=0;i<n;i++){
	// 	if (s3[i]=='1') val += (1ll<<pow--) ;
	// }
	cout << r << " " << r-1 << " " << val << ln ;
	return ;
}
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//	setIO() ;
	ll t = 1 ; 
	cin >> t ;
	for(ll i=1;i<=t;i++){
		//cout << "Case " << i << ": " ;
		solve() ;
	}
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define ln '\n'
#define ull unsigned  long long
#define ll long long 
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int> 
#define ld long double
#define ss second
using namespace std;


void setIO(const string io="a"){
    freopen((io+".in").c_str(),"r",stdin) ;
    freopen((io+".out").c_str(),"w",stdout) ;
}


void solve(){
	ll l , r ; cin >> l >> r ;
	ll n = log2(r)+1 ; 
	string s1('0',n) ; 
	ll a = r , i = n-1 ;
	while(a){
		if ((a&1ll)) s1[i--] = '1' ;
		a>>= 1ll ;
	}
	ll b = r-1 ; i = n-1 ;
	string s2('0',n) ; 
	while(b) {
		if ((b&1ll)) s2[i--] = '1' ;
		b >>= 1ll ;
	}
	string s3('0',n) ; 
	ll pow = n-1 , val = 0 ; 
	for(ll i=0;i<n;i++){
		if (val+(1<<pow)-1 < l or  s1[i]=='0' or s2[i]=='0' ) s3[i] = '1' , val += (1ll<<pow) ;
		pow-- ; 
	}
	// ll val = 0 , pow = n-1 ; 
	// for(ll i=0;i<n;i++){
	// 	if (s3[i]=='1') val += (1ll<<pow--) ;
	// }
	cout << r << " " << r-1 << " " << val << ln ;
	return ;
}
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//	setIO() ;
	ll t = 1 ; 
	cin >> t ;
	for(ll i=1;i<=t;i++){
		//cout << "Case " << i << ": " ;
		solve() ;
	}
    return 0;
}





Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define ln '\n'
#define ull unsigned  long long
#define ll long long 
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int> 
#define ld long double
#define ss second
using namespace std;


void setIO(const string io="a"){
    freopen((io+".in").c_str(),"r",stdin) ;
    freopen((io+".out").c_str(),"w",stdout) ;
}


void solve(){
	ll l , r ; cin >> l >> r ;
	ll n = log2(r)+1 ; 
	string s1 = "" ; for(ll i=0;i<n;i++) s1 += '0' ;
	ll a = r , i = n-1 ;
	while(a){
		if ((a&1ll)) s1[i--] = '1' ;
		a>>= 1ll ;
	}
	ll b = r-1 ; i = n-1 ;
	string s2 = "" ; for(ll i=0;i<n;i++) s2 += '0' ;
	while(b) {
		if ((b&1ll)) s2[i--] = '1' ;
		b >>= 1ll ;
	}
	string s3 = "" ; for(ll i=0;i<n;i++) s3 += '0' ;
	ll pow = n-1 , val = 0 ; 
	for(ll i=0;i<n;i++){
		if (val+(1<<pow)<r-1 and (val+(1<<pow)-1 < l or  s1[i]=='0' or s2[i]=='0') ) s3[i] = '1' , val += (1ll<<pow) ;
		pow-- ; 
	}
	//cout << s1 <<  " " << s2 << " " << s3 << ln ;
	cout << r << " " << r-1 << " " << val << ln ;
	return ;
}
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//setIO() ;
	ll t = 1 ; 
	cin >> t ;
	for(ll i=1;i<=t;i++){
		//cout << "Case " << i << ": " ;
		solve() ;
	}
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define ln '\n'
#define ull unsigned  long long
#define ll long long 
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int> 
#define ld long double
#define ss second
using namespace std;


void setIO(const string io="a"){
    freopen((io+".in").c_str(),"r",stdin) ;
    freopen((io+".out").c_str(),"w",stdout) ;
}
void f(ll a,ll b,ll c){
	cout << (a^b) + (a^c) + (b^c) << ln ;
}

void solve(){
	ll l , r ; cin >> l >> r ;
	ll n = log2(r)+1 ; 
	string s1 = "" ; for(ll i=0;i<n;i++) s1 += '0' ;
	ll a = r , i = n-1 ;
	while(a){
		if ((a&1ll)) s1[i] = '1' ;
		a>>= 1ll ; i-- ;
	}
	string s2 = "" ; for(ll i=0;i<n;i++) s2 += '0' ;
	ll b = l ;  i = n-1 ;
	while(b){
		if ((b&1ll)) s2[i] = '1' ;
		b>>= 1ll ; i-- ;
	}
	string s3 = "" ; for(ll i=0;i<n;i++) s3 += '0' ;
	ll pow = n-1 , val3 = 0 ; 
	for(ll i=0;i<n;i++){
		if (val3+(1ll<<pow)> r ) {
			pow-- ; continue ;
		}
		else if (val3 + (1ll<<pow)-1<l) s3[i] = '1'  ,val3 += (1ll<<pow); 
		else if (s1[i]=='0' and s2[i]=='0') s3[i] = '1' , val3 += (1ll<<pow); 
		pow-- ; 
	}
	if (l==val3) val3++ ;
	//cout << s1  << " " << s2 <<  " " << s3 << ln ;
	cout << r << " " <<  l<< " " << val3 << ln ;
	//f(r,l,val3) ;
	return ;
}
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//	setIO() ;
	ll t = 1 ; 
	cin >> t ;
	for(ll i=1;i<=t;i++){
		//cout << "Case " << i << ": " ;
		solve() ;
	}
    return 0;
}





Submission (verdict: Accepted):
#include <bits/stdc++.h>
 
using i64 = long long;
 
void solve() {
    int l, r;
    std::cin >> l >> r;
    int k = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    std::cout << a << " " << b << " " << c << "\n";
}
 
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int t = 1;
    std::cin >> t;
 
    while (t--) {
        solve();
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

using namespace std;

using ll = long long;

const int N = 2e5+5;

ll a[N],b[N];

int n,m;

multiset<ll> st;



inline bool work(ll x)

{

    if(x==1 && !st.count(x)) return false;

    if(st.count(x)){

        st.erase(st.find(x));

        return true;

    }else{

        ll x1=floor(1.0*x/2);

        ll x2=ceil(1.0*x/2);

        return work(x1)&&work(x2);

    }

}



void solve()

{

    st.clear();

    cin>>n>>m;

    ll sum = 0;

    for(int i=1;i<=n;i++) {cin>>a[i];st.insert(a[i]);sum+=a[i];}

    for(int i=1;i<=m;i++) {cin>>b[i];sum-=b[i];}

    if(sum!=0){

        cout <<"No"<<'\n';

        return ;

    }

    sort(b+1,b+1+m);

    bool flag = 1;

    for(int i=m;i>=1;i--){

        if(st.empty()){

            flag = 0;

            break;

        }

        if(st.size() && *st.rbegin()>b[i]){

            flag = 0;

            break;

        }else if(st.size() && *st.rbegin()==b[i]){

            st.erase(st.find(b[i]));

        }else{

            if(work(b[i])==0){

                flag = 0;

                break;

            }

        }

    }

    if(st.size()) flag = 0;

    if(flag) cout <<"Yes"<<'\n';

    else cout <<"No"<<'\n';

}



int main()

{

    ios::sync_with_stdio(false);

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



    int t;

    for(cin>>t;t--;){

        solve();

    }

    return 0;

}

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

using namespace std;

using ll = long long;

const int N = 2e5+5;

ll a[N],b[N];

int n,m;

map<ll,int> mp;



inline bool work(ll x)

{

    if(mp[x]) {return mp[x]--,true;}

    if(!x) return false;

    if(x&1) return work(x/2)&&work(x/2+1);

    return work(x/2)&&work(x/2);

}



void solve()

{

    mp.clear();

    cin>>n>>m;

    ll sum = 0;

    for(int i=1;i<=n;i++) {cin>>a[i];mp[a[i]]++;sum+=a[i];}

    for(int i=1;i<=m;i++) {cin>>b[i];sum-=b[i];}

    if(sum!=0){

        cout <<"No"<<'\n';

        return ;

    }

    bool flag = 1;

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

        if(!work(b[i])){

            flag = 0;

            break;

        }

    }

    if(flag) cout <<"Yes"<<'\n';

    else cout <<"No"<<'\n';

}



int main()

{

    ios::sync_with_stdio(false);

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



    int t;

    for(cin>>t;t--;){

        solve();

    }

    return 0;

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

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

using namespace std;

using ll = long long;

const int N = 2e5+5;

ll a[N],b[N];

int n,m;

multiset<ll> st;



inline bool work(ll x)

{

    if(x==1 && !st.count(x)) return false;

    if(st.count(x)){

        st.erase(st.find(x));

        return true;

    }else{

        ll x1=floor(1.0*x/2);

        ll x2=ceil(1.0*x/2);

        return work(x1)&&work(x2);

    }

}



void solve()

{

    st.clear();

    cin>>n>>m;

    for(int i=1;i<=n;i++) {cin>>a[i];st.insert(a[i]);}

    for(int i=1;i<=m;i++) cin>>b[i];

    sort(b+1,b+1+m);

    bool flag = 1;

    for(int i=m;i>=1;i--){

        if(st.empty()){

            flag = 0;

            break;

        }

        if(st.size() && *st.rbegin()>b[i]){

            flag = 0;

            break;

        }else if(st.size() && *st.rbegin()==b[i]){

            st.erase(st.find(b[i]));

        }else{

            if(work(b[i])==0){

                flag = 0;

                break;

            }

        }

    }

    if(st.size()) flag = 0;

    if(flag) cout <<"Yes"<<'\n';

    else cout <<"No"<<'\n';

}



int main()

{

    ios::sync_with_stdio(false);

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



    int t;

    for(cin>>t;t--;){

        solve();

    }

    return 0;

}

Submission (verdict: Time limit exceeded on test 11):
#include<bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = 2e5+5;

ll a[N],b[N];

int n,m;

multiset<ll> st;



inline bool work(ll x)

{

    if(x==1 && !st.count(x)) return false;

    if(st.count(x)){

        st.erase(st.find(x));

        return true;

    }else{

        ll x1=floor(1.0*x/2);

        ll x2=ceil(1.0*x/2);

        return work(x1)&&work(x2);

    }

}



void solve()

{

    st.clear();

    cin>>n>>m;

    ll sum = 0;

    for(int i=1;i<=n;i++) {cin>>a[i];st.insert(a[i]);sum+=a[i];}

    for(int i=1;i<=m;i++) {cin>>b[i];sum-=b[i];}

    if(sum!=0){

        cout <<"No"<<'\n';

        return ;

    }

    sort(b+1,b+1+m);

    bool flag = 1;

    for(int i=m;i>=1;i--){

        if(st.empty()){

            flag = 0;

            break;

        }

        if(st.size() && *st.rbegin()>b[i]){

            flag = 0;

            break;

        }else if(st.size() && *st.rbegin()==b[i]){

            st.erase(st.find(b[i]));

        }else{

            if(work(b[i])==0){

                flag = 0;

                break;

            }

        }

    }

    if(st.size()) flag = 0;

    if(flag) cout <<"Yes"<<'\n';

    else cout <<"No"<<'\n';

}



int main()

{

    ios::sync_with_stdio(false);

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



    int t;

    for(cin>>t;t--;){

        solve();

    }

    return 0;

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


Submission (verdict: Time limit exceeded on test 7):
#include<bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = 2e5+5;

ll a[N],b[N];

int n,m;

multiset<ll> st;



inline bool work(ll x)

{

    if(x==1 && !st.count(x)) return false;

    if(st.count(x)){

        st.erase(st.find(x));

        return true;

    }else{

        ll x1=floor(1.0*x/2);

        ll x2=ceil(1.0*x/2);

        return work(x1)&&work(x2);

    }

}



void solve()

{

    st.clear();

    cin>>n>>m;

    for(int i=1;i<=n;i++) {cin>>a[i];st.insert(a[i]);}

    for(int i=1;i<=m;i++) cin>>b[i];

    sort(b+1,b+1+m);

    bool flag = 1;

    for(int i=m;i>=1;i--){

        if(st.empty()){

            flag = 0;

            break;

        }

        if(st.size() && *st.rbegin()>b[i]){

            flag = 0;

            break;

        }else if(st.size() && *st.rbegin()==b[i]){

            st.erase(st.find(b[i]));

        }else{

            if(work(b[i])==0){

                flag = 0;

                break;

            }

        }

    }

    if(st.size()) flag = 0;

    if(flag) cout <<"Yes"<<'\n';

    else cout <<"No"<<'\n';

}



int main()

{

    ios::sync_with_stdio(false);

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



    int t;

    for(cin>>t;t--;){

        solve();

    }

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 7):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+12;
ll m,n,t,d[maxn],r[maxn];

int main()
{
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
            int max=s[i]-48,maxj=i;
            for(int j=i+1;j<s.size()&&j<=i+9;j++)
            {
                if(char(s[j]-j+i)>s[i] && int(s[j]-j+i-48)>max)
                {
                    max=int(s[j]-j+i-48);
                    maxj=j;
                    //cout<<maxj<<" ";
                }
            }
            s[maxj]=char(max+48);
            s=s.substr(0,i)+s[maxj]+s.substr(i,maxj-i)+s.substr(maxj+1);
            //cout<<s<<endl;
        }
        cout<<s<<endl;
    }
    return 0;
}



Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+12;
ll m,n,t,d[maxn],r[maxn];

int main()
{
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
            int max=s[i]-48,maxj=i;
            for(int j=i+1;j<s.size()&&j<=i+9;j++)
            {
                if(char(s[j]-j+i)>s[i] && int(s[j]-j+i-48)>max)
                {
                    max=int(s[j]-j+i-48);
                    maxj=j;
                    //cout<<maxj<<" ";
                }
            }
            s[maxj]=char(max+48);
            for(int j=maxj;j>i;j--)
            {
                swap(s[j],s[j-1]);
            }
        }
        cout<<s<<endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+12;
ll m,n,t,d[maxn],r[maxn];

int main()
{
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
            int max=s[i]-48,maxj=i;
            for(int j=i+1;j<s.size()&&j<=i+9;j++)
            {
                if(char(s[j]-j+i)>s[i] && int(s[j]-j+i-48)>max)
                {
                    max=int(s[j]-j+i-48);
                    maxj=j;
                    //cout<<maxj<<" ";
                }
            }
            s[maxj]=char(max+48);
            s=s.substr(0,i)+s[maxj]+s.substr(i,maxj-i)+s.substr(maxj+1);
            cout<<s<<endl;
        }
        cout<<s<<endl;
    }
    return 0;
}



Submission (verdict: Time limit exceeded on test 7):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+12;
ll m,n,t,d[maxn],r[maxn];

int main()
{
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
            int max=s[i]-48,maxj=i;
            for(int j=i+1;j<s.size()&&j<=i+9;j++)
            {
                if(char(s[j]-j+i)>s[i] && int(s[j]-j+i-48)>max)
                {
                    max=int(s[j]-j+i-48);
                    maxj=j;
                    //cout<<maxj<<" ";
                }
            }
            s[maxj]=char(max+48);
            s=s.substr(0,i)+s[maxj]+s.substr(i,maxj-i)+s.substr(maxj+1);
            //cout<<s<<endl;
        }
        cout<<s<<endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+12;
ll m,n,t,d[maxn],r[maxn];

int main()
{
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
            int max=s[i]-48,maxj=i;
            for(int j=i+1;j<s.size()&&j<=i+9;j++)
            {
                if(char(s[j]-j+i)>s[i] && int(s[j]-j+i-48)>max)
                {
                    max=int(s[j]-j+i-48);
                    maxj=j;
                    //cout<<maxj<<" ";
                }
            }
            s[maxj]=char(max+48);
            s=s.substr(0,i)+s[maxj]+s.substr(i,maxj-i)+s.substr(maxj+1);
            cout<<s<<endl;
        }
        cout<<s<<endl;
    }
    return 0;
}
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;
#define ll long long

void solve() {
    ll n;
    cin >> n;

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


    bool flag = false;
    int i = 0, j = n - 1;
    for (int i = 0; i < n; i++) {
        if (a[0] < a[1]) {
            flag = true;
        }
    }
    if (flag == true) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t;
    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>

using namespace std;
#define ll long long

void solve() {
    ll n;
    cin >> n;

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


    bool flag = false;
    int i = 0, j = n - 1;
    for (int i = 0; i < n; i++) {
        if (a[0] < a[1]) {
            flag = true;
        }
    }
    if (flag == true) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.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;
#define ll long long

void solve() {
    int n;
    cin >> n;
    vector < ll > a(n);

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

    for (int i = 0; i < n - 2; i++) {
        if (a[i] > a[i + 1]) {
            cout << "NO" << endl;
            return;
        } else {
            int temp = min(a[i], a[i + 1]);
            a[i] -= temp;
            a[i + 1] -= temp;
        }
    }
    cout << "YES" << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t;
    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>

using namespace std;
#define ll long long

void solve() {
    int n;
    cin >> n;
    vector < ll > a(n);

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

    for (int i = 0; i < n - 2; i++) {
        if (a[i] > a[i + 1]) {
            cout << "NO" << endl;
            return;
        } else {
            int temp = min(a[i], a[i + 1]);
            a[i] -= temp;
            a[i + 1] -= temp;
        }
    }
    cout << "YES" << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

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

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

void solve() {
    ll n;
    cin >> n;
    vector < ll > a(n);

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

    for (int i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            cout << "NO" << endl;
            return;
        } else {
            int temp = min(a[i], a[i + 1]);
            a[i] -= temp;
            a[i + 1] -= temp;
        }
    }
    cout << "YES" << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

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