ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
       string s;
       cin>>s;
       vector<char> vec;

       for(int j=0;j<s.length();j++){
              for(int k=j;k>0;k--){
                     if(s[k]-s[k-1]>1){
                        int temp=s[k]-1;
                        s[k]=s[k-1];
                        s[k-1]=temp;
                     }
              }
       }  
           cout<<s<<endl;
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
       string s;
       cin>>s;
       vector<char> vec;

       for(int j=0;j<s.length();j++){
              for(int k=j;k>max(0,k-10);k--){
                     if(s[k]-s[k-1]>1){
                        int temp=s[k]-1;
                        s[k]=s[k-1];
                        s[k-1]=temp;
                     }
              }
       }  
           cout<<s<<endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
       string s;
       cin>>s;
       vector<char> vec;

       for(int j=0;j<s.length();j++){
              for(int k=j;k>0;k--){
                     if(s[k]-s[k-1]>1){
                        int temp=s[k]-1;
                        s[k]=s[k-1];
                        s[k-1]=temp;
                     }
              }
       }  
           cout<<s<<endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#define ll long long

using namespace std;

void solve();

int main()

{

    ll t;

    cin>>t;

    while(t--)

	{

		int n;

		int x,y;

		cin>>n>>x>>y;

		int a[n];

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

		{

			cin>>a[i];

		}

		sort(a,a+n);

		int z=(y-x)+1;

		int ans=0;

		for(int i=0;i<z;i++)

		{

			ans+=a[i];

		}

		cout<<ans<<endl;

    }

}



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

#define ll long long

using namespace std;

void solve();

int main()

{

    ll t;

    cin>>t;

    while(t--)

	{

		int n;

		int x,y;

		cin>>n>>x>>y;

		vector<int>a,b,c;

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

		{

			int d;

			cin>>d;

			if(i<x-1)

			a.push_back(d);

			else if(i>=x-1 and i<y)

			b.push_back(d);

			else 

			c.push_back(d);

			

		}

		sort(a.begin(),a.end());

		sort(b.begin(),b.end());

		sort(c.begin(),c.end());

		int ans1=0,ans2=0;

		int n1=b.size()-1;

		int n2=a.size()-1,x1=0;

		for(int i=n1;i>=0;i--)

		{

			if(x1<=n2)

			{

				ans1+=min(a[x1],b[i]);

				x1++;

			}

			else

			{

			    ans1+=b[i];	

			}

		}

		

		int n3=c.size()-1,x2=0;

		for(int i=n1;i>=0;i--)

		{

			if(x2<=n3)

			{

				ans2+=min(c[x2],b[i]);

				x2++;

			}

			else

			{

			    ans2+=b[i];	

			}

		}

		cout<<min(ans1,ans2)<<endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

#define ll long long

using namespace std;

void solve();

int main()

{

    ll t;

    cin>>t;

    while(t--)

	{

		int n;

		int x,y;

		cin>>n>>x>>y;

		int a[n];

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

		{

			cin>>a[i];

		}

		sort(a,a+n);

		int z=(y-x)+1;

		int ans=0;

		for(int i=0;i<z;i++)

		{

			ans+=a[i];

		}

		cout<<ans<<endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve();
int main()
{
    ll t;
    cin>>t;
    while(t--)
	{
		ll n;
		ll x,y;
		cin>>n>>x>>y;
		vector<ll>a,b,c;
		for(ll i=0;i<n;i++)
		{
			ll d;
			cin>>d;
			if(i<x-1)
			a.push_back(d);
			else if(i>=x-1 and i<y)
			b.push_back(d);
			else 
			c.push_back(d);
			
		}
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		sort(c.begin(),c.end());
		ll ans1=0,ans2=0;
		ll n1=b.size()-1;
		ll n2=a.size()-1,x1=0;
		for(ll i=n1;i>=0;i--)
		{
			if(x1<=n2)
			{
				ans1+=min(a[x1],b[i]);
				x1++;
			}
			else
			{
			    ans1+=b[i];	
			}
		}
		
		ll n3=c.size()-1,x2=0;
		for(ll i=n1;i>=0;i--)
		{
			if(x2<=n3)
			{
				ans2+=min(c[x2],b[i]);
				x2++;
			}
			else
			{
			    ans2+=b[i];	
			}
		}
		cout<<min(ans1,ans2)<<endl;
    }
}


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

#define ll long long

using namespace std;

void solve();

int main()

{

    ll t;

    cin>>t;

    while(t--)

	{

		ll n;

		ll x,y;

		cin>>n>>x>>y;

		vector<ll>a,b,c;

		for(ll i=0;i<n;i++)

		{

			ll d;

			cin>>d;

			if(i<x-1)

			a.push_back(d);

			else if(i>=x-1 and i<y)

			b.push_back(d);

			else 

			c.push_back(d);

			

		}

		sort(a.begin(),a.end());

		sort(b.begin(),b.end());

		sort(c.begin(),c.end());

		ll ans1=0,ans2=0;

		int n1=b.size()-1;

		int n2=a.size()-1,x1=0;

		for(int i=n1;i>=0;i--)

		{

			if(x1<=n2)

			{

				ans1+=min(a[x1],b[i]);

				x1++;

			}

			else

			{

			    ans1+=b[i];	

			}

		}

		

		int n3=c.size()-1,x2=0;

		for(int i=n1;i>=0;i--)

		{

			if(x2<=n3)

			{

				ans2+=min(c[x2],b[i]);

				x2++;

			}

			else

			{

			    ans2+=b[i];	

			}

		}

		cout<<min(ans1,ans2)<<endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#define ll long long

using namespace std;

void solve();

int main()

{

    ll t;

    cin>>t;

    while(t--)

	{

		int n;

		int x,y;

		cin>>n>>x>>y;

		vector<int>a,b,c;

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

		{

			int d;

			cin>>d;

			if(i<x-1)

			a.push_back(d);

			else if(i>=x-1 and i<y)

			b.push_back(d);

			else 

			c.push_back(d);

			

		}

		sort(a.begin(),a.end());

		sort(b.begin(),b.end());

		sort(c.begin(),c.end());

		int ans1=0,ans2=0;

		int n1=b.size()-1;

		int n2=a.size()-1,x1=0;

		for(int i=n1;i>=0;i--)

		{

			if(x1<=n2)

			{

				ans1+=min(a[x1],b[i]);

				x1++;

			}

			else

			{

			    ans1+=b[i];	

			}

		}

		

		int n3=c.size()-1,x2=0;

		for(int i=n1;i>=0;i--)

		{

			if(x2<=n3)

			{

				ans2+=min(c[x2],b[i]);

				x2++;

			}

			else

			{

			    ans2+=b[i];	

			}

		}

		cout<<min(ans1,ans2)<<endl;

    }

}



Submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve();
int main()
{
    ll t;
    cin>>t;
    while(t--)
	{
		ll n;
		ll x,y;
		cin>>n>>x>>y;
		vector<ll>a,b,c;
		for(ll i=0;i<n;i++)
		{
			ll d;
			cin>>d;
			if(i<x-1)
			a.push_back(d);
			else if(i>=x-1 and i<y)
			b.push_back(d);
			else 
			c.push_back(d);
			
		}
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		sort(c.begin(),c.end());
		ll ans1=0,ans2=0;
		ll n1=b.size()-1;
		ll n2=a.size()-1,x1=0;
		for(ll i=n1;i>=0;i--)
		{
			if(x1<=n2)
			{
				ans1+=min(a[x1],b[i]);
				x1++;
			}
			else
			{
			    ans1+=b[i];	
			}
		}
		
		ll n3=c.size()-1,x2=0;
		for(ll i=n1;i>=0;i--)
		{
			if(x2<=n3)
			{
				ans2+=min(c[x2],b[i]);
				x2++;
			}
			else
			{
			    ans2+=b[i];	
			}
		}
		cout<<min(ans1,ans2)<<endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// Sikh rha hu
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f0(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i < n; i++)
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define pb push_back
void fillnums(vector<int> &nums, int &n)
{
    f0(i, n)
    {
        int x;
        cin >> x;
        nums.push_back(x);
    }
}
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> nums;
    fillnums(nums, n);

    sort(nums.begin(), nums.end());
    int val = r - l + 1;
    int sum = 0;
    for (int i = 0; i < val; i++)
    {
        sum += nums[i];
    }
    cout << sum << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
// Sikh rha hu
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f0(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i < n; i++)
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define pb push_back

int minKSizeSubarrayCircular(vector<int> &arr, int k)
{
    int n = arr.size();
    if (k == n)
        return accumulate(arr.begin(), arr.end(), 0);

    // Find minimum sum subarray of size k using sliding window
    int minSum = INT_MAX, windowSum = 0;
    for (int i = 0; i < k; i++)
    {
        windowSum += arr[i];
    }
    minSum = windowSum;

    for (int i = k; i < n; i++)
    {
        windowSum += arr[i] - arr[i - k];
        minSum = min(minSum, windowSum);
    }

    // Find the total sum and max sum of size (n-k) (for circular case)
    int totalSum = accumulate(arr.begin(), arr.end(), 0);
    int maxSum = INT_MIN, compSum = 0;

    for (int i = 0; i < n - k; i++)
    {
        compSum += arr[i];
    }
    maxSum = compSum;

    for (int i = n - k; i < n; i++)
    {
        compSum += arr[i] - arr[i - (n - k)];
        maxSum = max(maxSum, compSum);
    }

    int circularMinSum = totalSum - maxSum;

    return min(minSum, circularMinSum);
}

void fillnums(vector<int> &nums, int &n)
{
    f0(i, n)
    {
        int x;
        cin >> x;
        nums.push_back(x);
    }
}
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> nums;
    fillnums(nums, n);

    sort(nums.begin(), nums.end());
    int val = r - l + 1;
    int sum = minKSizeSubarrayCircular(nums, val);
    cout << sum << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// Sikh rha hu
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f0(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i < n; i++)
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define pb push_back

int minKSizeSubarrayCircular(vector<int> &arr, int k)
{
    int n = arr.size();
    if (k == n)
        return accumulate(arr.begin(), arr.end(), 0);

    // Find minimum sum subarray of size k using sliding window
    int minSum = INT_MAX, windowSum = 0;
    for (int i = 0; i < k; i++)
    {
        windowSum += arr[i];
    }
    minSum = windowSum;

    for (int i = k; i < n; i++)
    {
        windowSum += arr[i] - arr[i - k];
        minSum = min(minSum, windowSum);
    }

    // Find the total sum and max sum of size (n-k) (for circular case)
    int totalSum = accumulate(arr.begin(), arr.end(), 0);
    int maxSum = INT_MIN, compSum = 0;

    for (int i = 0; i < n - k; i++)
    {
        compSum += arr[i];
    }
    maxSum = compSum;

    for (int i = n - k; i < n; i++)
    {
        compSum += arr[i] - arr[i - (n - k)];
        maxSum = max(maxSum, compSum);
    }

    int circularMinSum = totalSum - maxSum;

    return min(minSum, circularMinSum);
}

void fillnums(vector<int> &nums, int &n)
{
    f0(i, n)
    {
        int x;
        cin >> x;
        nums.push_back(x);
    }
}
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> nums;
    fillnums(nums, n);

    sort(nums.begin(), nums.end());
    int val = r - l + 1;
    int sum = minKSizeSubarrayCircular(nums, val);
    cout << sum << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f0(i, n) for (int i = 0; i < n; i++)
#define pb push_back

void fillnums(vector<int> &nums, int &n)
{
    f0(i, n)
    {
        int x;
        cin >> x;
        nums.pb(x);
    }
}

void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> nums;
    fillnums(nums, n);

    int val = r - l + 1; 

    
    vector<int> left(nums.begin(), nums.begin() + r);
    vector<int> right(nums.begin() + l - 1, nums.end());

    
    sort(left.begin(), left.end());
    sort(right.begin(), right.end());

   
    int leftSum = (left.size() >= val) ? accumulate(left.begin(), left.begin() + val, 0LL) : LLONG_MAX;
    int rightSum = (right.size() >= val) ? accumulate(right.begin(), right.begin() + val, 0LL) : LLONG_MAX;


    cout << min(leftSum, rightSum) << "\n";
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
// Sikh rha hu
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f0(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i < n; i++)
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define pb push_back
void fillnums(vector<int> &nums, int &n)
{
    f0(i, n)
    {
        int x;
        cin >> x;
        nums.push_back(x);
    }
}
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> nums;
    fillnums(nums, n);

    sort(nums.begin(), nums.end());
    int val = r - l + 1;
    int sum = 0;
    for (int i = 0; i < val; i++)
    {
        sum += nums[i];
    }
    cout << sum << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

#define minus1 cout<<-1<<endl;

#include<stdio.h>

#define Yes  cout<<"YES"<<endl;

#define No cout<<"NO"<<endl;

#define pb push_back

#define nl cout<<endl;

#define un unsigned;

#define FOR(l,r) for(ll i = l; i < r;i++)

#define frr(l,r) for(ll i = l; i >=r;i--)

using namespace std;

using ll = long long;









/*****************************************CODE*****************************************/





bool sortbysec(const pair<ll,ll> &a,

              const pair<ll,ll> &b)

{

    return (a.second < b.second);

}



bool sortBySecDesc(const pair<ll,ll> &a,

              const pair<ll,ll> &b)

{

    return (a.second > b.second);

}



bool customComparator(const pair<int, int>& a, const pair<int, int>& b) {

    if (a.first == b.first) {

        return a.second > b.second; // Sort in descending order of second element if first elements are equal

    }

    return a.first < b.first; // Sort in ascending order of first element

}





bool secDescFstAsc(const std::pair<int, int>& a, const std::pair<int, int>& b) {

    if (a.second != b.second) {

        return a.second < b.second; // Sort in ascending order based on second element

    } else {

        return a.first > b.first; // If second elements are equal, sort in descending order based on first element

    }

}



long long lcm(long long x, long long y){

    return (min(x, y)/__gcd(x,y))*max(x,y);

}

string s;



bool check(int i, ll n){

    if(i < 0 or i + 3 >= n) return false;



    if(s[i] == '1' and s[i + 1] == '1' and s[i + 2] == '0' and s[i + 3] == '0') return 1;

    return 0;

}



void sol(){

    int n, l, r;

    cin>>n>>l>>r;



    l--;

    r--;



    vector<int>a(n);



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



    int len = r - l + 1;

    vector<int>b = a;

    long long ans1 = 0, ans = 0;

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

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

    for(int i = 0;i < len;i++) ans += a[i];

    for(int i = l; i < l + len; i++) ans1+= b[i];



    cout<<min(ans,ans1)<<endl;



}



int main() {

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll t;

    cin>>t;







    int i = 1;

    while(t--) {

//        cout<<i++<<' ';

        sol();

//        cout<<endl;

    }



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


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll N = 2e5 + 10, LG = 20, mod = 1e9 + 7;

void burn()
{
    int l, r;
    cin >> l >> r;
    ll a, b, c;
    a = b = c = 0;
    for(int i = 29; i >= 0; i--)
    {
        if(a > b)
            swap(a, b);
        if(b > c)
            swap(b, c);
        if(a > c)
            swap(a, c);
        int must = ((a | ((1 << i) - 1)) < l);
        must += ((b | ((1 << i) - 1)) < l);
        must += ((c | ((1 << i) - 1)) < l);
        if((a | ((1 << i) - 1)) < l)
            a |= (1 << i);
        if((b | ((1 << i) - 1)) < l)
            b |= (1 << i);
        if((c | ((1 << i) - 1)) < l)
            c |= (1 << i);
        if(!must && (a |(1 << i)) <= r)
            a |= (1 << i);
    }
    if(a > b)
        swap(a, b);
    if(b > c)
        swap(b, c);
    if(a > c)
        swap(a, c);
//    cout << a << ' ' << b << ' ' << c << '\n';
    
    if(a == b)
    {
        int ii = -1;
        bool don = false;
        for(int i = 29; i >= 0; i--)
        {
            if(((1 << i) & a) && !((1 << i) & b) && (a ^ (1 << i)) && !don)
            {
                don = true;
                ii = i;
                a ^= (1 << i);
                continue;
            }
            if(don && (1 << i) & a)
                a ^= (1 << i);
            
        }
//        cout << ii << '\n';
        int pos = -1;
        for(int i = 29; i >= 0; i--)
        {
            if((1 << i) & a || i == ii)
                continue;
            int add = (ii == -1 ?0 :(ii < i ? (1 << ii) : 0));
            int cnt = ((1 << i) & b) > 0;
            cnt += ((1 << i) & c) > 0;
            if(!cnt && (a | (1 << i)) <= r)
                a |= (1 << i);
            else if((a | (1 << i)) <= r)
                pos = i;
            if((a | ((1 << i) - 1) - add) < l)
                a |= (1 << i);
        }
        if(a == b)
           assert(pos != -1), a |= (1 << pos);
    }
    assert(a != b && b != c);
    cout << a << ' ' << b << ' ' << c << '\n';
    
}

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
      cin >> t;
    while (t--)
        burn();
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define N 500010
const ll INF = 1e18 + 10;
#define mod 998244353
//map<ll, ll>v;
ll n, maxn, k, m, q, p, pos;
ll a[N], b[N], c[N];
ll vis[N];
ll dis[N];
vector<ll>v;
ll sum, cnt;
struct node { int id, x; }nod[N];
bool cmp(node x, node y) { return x.x < y.x; }
ll num[3005][3005],f[3005][3005];
ll s[N];
map<ll, ll>mp;
void solve() {
	ll l, r;
	cin >> l >> r;
	k = __lg(l ^ r);
	ll x = (r >> k) << k, y = x - 1,z;
	if (y == 1)z = x + 1;
	else z = x - 2;
	cout << x << " " << y << " " << z << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	//	freopen("input.txt","r",stdin);
	//  freopen("output.txt","w",stdout);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll N = 2e5 + 10, LG = 20, mod = 1e9 + 7;

void burn()
{
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for(int i = 29; i >= 0; i--)
    {
        if((a | (1 << i)) <= r)
            a |= (1 << i);
        else if((b | (1 << i)) <= r)
            b |= (1 << i);
        if((b | ((1 << i) - 1)) < l) {
            b |= (1 << i);
            a ^= (1 << i);
            if((((1 << i) - 1) | a) >= l)
                a ^= (1 << i);
            else
                a ^= (1 << i);
        }
    }
    if(b - 1 >= l && b - 1 != a)
        c = b - 1;
    else if(b + 1 <= r && b + 1 != a)
        c = b + 1;
    else if(a - 1 >= l && a - 1 != b)
        c = a - 1;
    else if(a + 1 <= r && a + 1 != b)
        c = a + 1;
    cout << a << ' ' << b << ' ' << c << '\n';
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
      cin >> t;
    while (t--)
        burn();
}
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;

int main() {
    int t, n, i, bef, aft, subs = 0;
    scanf("%d", &t);
    while (t--) {
        scanf("%d", &n);
        bool possible = true;

        scanf("%d", &bef);
        for (i = 1; i < n; i++) {
            scanf("%d", &aft);
            if (subs > aft) {
                possible = false;
            }
            subs = aft - bef;
            if (subs < 0)
                subs = 0;
            bef = subs;
        }
        printf("%s\n", possible ? "YES":"NO");
    }
}

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

    int main() {
        int t, n, i, bef, aft, subs = 0;
        scanf("%d", &t);
        while (t--) {
            scanf("%d", &n);
            bool possible = true;

            scanf("%d", &bef);
            for (i = 1; i < n; i++) {
                scanf("%d", &aft);
                if (subs > aft || subs < 0) {
                    possible = false;
                }
                subs = aft - bef;
                bef = subs;
            }
            printf("%s\n", possible ? "YES":"NO");
        }
    }
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

    int main() {
        int t, n, i, bef, aft, subs = 0;
        scanf("%d", &t);
        while (t--) {
            scanf("%d", &n);
            bool possible = true;

            scanf("%d", &bef);
            for (i = 1; i < n; i++) {
                scanf("%d", &aft);
                if (subs > aft || subs < 0) {
                    possible = false;
                }
                subs = aft - bef;
                bef = subs;
            }
            printf("%s\n", possible ? "YES":"NO");
        }
    }

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

    int main() {
        int t, n, i, bef, aft, subs = 0;
        scanf("%d", &t);
        while (t--) {
            scanf("%d", &n);
            bool possible = true;

            scanf("%d %d", &bef, &aft);
            for (i = 2; i < n; i++) {
                subs = aft - bef;
                bef = subs;
                scanf("%d", &aft);
                if (subs > aft || subs < 0) {
                    possible = false;
                }
            }
            if (n == 2 && aft < bef)
                possible = false;
            printf("%s\n", possible ? "YES":"NO");
        }
    }