ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
﻿#include<iomanip>
#include<cstring>
#include<vector>
#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
using namespace std;




int main() {
	int t;
	cin >> t;
	long long ans = 0;
	for (int l = 0; l < t; l++) {
		int n;
		cin >> n;
		long long ans = -1e18;
		long long sum = 0;
		vector<long long> a;
		a.resize(n);
		for (int i = 0; i < n;i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n;i++) {
			long long sum = 0;
			for (int j = 0; j < n - i;j++) {
				sum += a[j];
			}
			if (n == 1) {
				ans = sum;
				break;
			}
			ans = max(ans, max(sum, -sum));
			for (int j = 0; j < n - i - 1;j++) {
				a[j] = a[j + 1] - a[j];
			}
		}
		cout << ans << endl;


	}

}


Submission (verdict: Wrong answer on test 1):
﻿#include<iomanip>
#include<cstring>
#include<vector>
#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
using namespace std;




int main() {
	int t;
	cin >> t;
	long long ans = 0;
	for (int l = 0; l < t; l++) {
		int n;
		cin >> n;
		long long ans = -1e18;
		long long sum = 0;
		vector<long long> a;
		a.resize(n);
		for (int i = 0; i < n;i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n;i++) {
			long long sum = 0;
			for (int j = 0; j < n - i;j++) {
				sum += a[j];
			}
			if (n == 1 || n == 2) {
				ans = sum;
				continue;
			}
			ans = max(ans, max(sum, -sum));
			for (int j = 0; j < n - i - 1;j++) {
				a[j] = a[j + 1] - a[j];
			}
		}
		cout << ans << endl;


	}

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

Previous submission (verdict: Wrong answer on test 1):
﻿#include<iomanip>
#include<cstring>
#include<vector>
#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
using namespace std;




int main() {
	int t;
	cin >> t;
	long long ans = 0;
	for (int l = 0; l < t; l++) {
		int n;
		cin >> n;
		long long ans = -1e18;
		long long sum = 0;
		vector<long long> a;
		a.resize(n);
		for (int i = 0; i < n;i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n;i++) {
			long long sum = 0;
			for (int j = 0; j < n - i;j++) {
				sum += a[j];
			}
			if (n == 1 || n == 2) {
				ans = sum;
				continue;
			}
			ans = max(ans, max(sum, -sum));
			for (int j = 0; j < n - i - 1;j++) {
				a[j] = a[j + 1] - a[j];
			}
		}
		cout << ans << endl;


	}

}


Submission (verdict: Accepted):
﻿#include<iomanip>
#include<cstring>
#include<vector>
#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
using namespace std;




int main() {
	int t;
	cin >> t;
	long long ans = 0;
	for (int l = 0; l < t; l++) {
		int n;
		cin >> n;
		long long ans = -1e18;
		long long sum = 0;
		vector<long long> a;
		a.resize(n);
		for (int i = 0; i < n;i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n;i++) {
			long long sum = 0;
			for (int j = 0; j < n - i;j++) {
				sum += a[j];
			}
			if (i == 0) {
				ans = max(ans,sum);
			}
			else {
				ans = max(ans, max(sum, -sum));
			}
			for (int j = 0; j < n - i - 1;j++) {
				a[j] = a[j + 1] - a[j];
			}
		}
		cout << ans << endl;


	}

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


Submission (verdict: Wrong answer on test 2):
﻿#include<iomanip>
#include<cstring>
#include<vector>
#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
using namespace std;




int main() {
	int t;
	cin >> t;
	long long ans = 0;
	for (int l = 0; l < t; l++) {
		int n;
		cin >> n;
		long long ans = -1e18;
		long long sum = 0;
		vector<long long> a;
		a.resize(n);
		for (int i = 0; i < n;i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n;i++) {
			long long sum = 0;
			for (int j = 0; j < n - i;j++) {
				sum += a[j];
			}
			if (n == 1) {
				ans = sum;
				break;
			}
			ans = max(ans, max(sum, -sum));
			for (int j = 0; j < n - i - 1;j++) {
				a[j] = a[j + 1] - a[j];
			}
		}
		cout << ans << endl;


	}

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


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <queue>
#include <ranges>
#include <string>
#include <utility>
#include <vector>

constexpr int offset = 1;

void solve() {
    std::string s;
    std::cin >> s;
    std::priority_queue<std::pair<int, int>> q;

    int n = s.length();
    std::vector<int> c(n + offset, 0);
    auto lowbit = [&](int x) { return x & (-x); };
    auto add    = [&](int pos, int v) {
        for (int i = pos + offset; i < n + offset; i += lowbit(i)) c[i] += v;
    };
    auto sum = [&](int pos) {
        int res = 0;
        for (int i = pos + offset; i >= offset; i -= lowbit(i)) res += c[i];
        return res;
    };

    for (auto [i, c] : std::views::enumerate(s)) q.push({c - '0' - i, i});

    for (auto i : std::views::iota(0)) {
        if (q.empty()) break;
        auto [v, p] = q.top();
        q.pop();
        std::cout << (i <= p ? v + i : v + i - sum(n - 1) + sum(p));
        add(p, 1);
    }
    std::cout << "\n";
    // std::cerr << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(0);

    int t;
    std::cin >> t;
    for (auto i : std::views::iota(0, t)) solve();
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <queue>
#include <ranges>
#include <string>
#include <utility>
#include <vector>

constexpr int offset = 1;

void solve() {
    std::string s;
    std::cin >> s;
    std::priority_queue<std::pair<int, int>> q;

    int n = s.length();
    std::vector<int> c(n + offset, 0);
    auto lowbit = [&](int x) { return x & (-x); };
    auto add    = [&](int pos, int v) {
        for (int i = pos + offset; i < n + offset; i += lowbit(i)) c[i] += v;
    };
    auto sum = [&](int pos) {
        int res = 0;
        for (int i = pos + offset; i >= offset; i -= lowbit(i)) res += c[i];
        return res;
    };

    for (auto [i, c] : s | std::views::reverse | std::views::enumerate) q.push({c - '0' + i + 1 - n, n - 1 - i});

    for (auto i : std::views::iota(0)) {
        if (q.empty()) break;
        auto [v, p] = q.top();
        q.pop();
        std::cout << (i <= p ? v + i : v + i - sum(n - 1) + sum(p));
        add(p, 1);
    }
    std::cout << "\n";
    // std::cerr << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(0);

    int t;
    std::cin >> t;
    for (auto i : std::views::iota(0, t)) solve();
}

Submission (verdict: Accepted):
#include <algorithm>
#include <iostream>
#include <queue>
#include <ranges>
#include <string>
#include <vector>
constexpr int offset = 1;

void solve() {
    std::string s;
    std::cin >> s;
    int n = s.length();
    std::vector<int> used(n + 1, 0);
    std::vector<int> a(n);
    for (auto [i, c] : std::views::enumerate(s)) a[i] = c - '0';

    for (auto i : std::views::iota(0)) {
        if (i >= n) break;
        int end = std::min(i + 10, n);
        int w = -1, pos = n;
        for (int j = i; j < end; j++) {
            if (!used[i] && w < a[j] - (j - i)) {
                w   = a[j] - (j - i);
                pos = j;
            }
        }
        used[i] = 1;
        std::cout << w;
        for (int j = pos; j > i; j--) std::swap(a[j], a[j - 1]);
    }
    std::cout << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(0);

    int t;
    std::cin >> t;
    for (auto i : std::views::iota(0, t)) solve();
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <queue>
#include <ranges>
#include <string>
#include <utility>
#include <vector>

constexpr int offset = 1;

void solve() {
    std::string s;
    std::cin >> s;
    std::priority_queue<std::pair<int, int>> q;

    int n = s.length();
    std::vector<int> c(n + offset, 0);
    auto lowbit = [&](int x) { return x & (-x); };
    auto add    = [&](int pos, int v) {
        for (int i = pos + offset; i < n + offset; i += lowbit(i)) c[i] += v;
    };
    auto sum = [&](int pos) {
        int res = 0;
        for (int i = pos + offset; i >= offset; i -= lowbit(i)) res += c[i];
        return res;
    };

    for (auto [i, c] : std::views::enumerate(s)) q.push({c - '0' - i, i});

    for (auto i : std::views::iota(0)) {
        if (q.empty()) break;
        auto [v, p] = q.top();
        q.pop();
        std::cout << (i <= p ? v + i : v + i - sum(n - 1) + sum(p));
        add(p, 1);
    }
    std::cout << "\n";
    // std::cerr << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(0);

    int t;
    std::cin >> t;
    for (auto i : std::views::iota(0, t)) solve();
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <queue>
#include <ranges>
#include <string>
#include <utility>
#include <vector>

constexpr int offset = 1;

void solve() {
    std::string s;
    std::cin >> s;
    std::priority_queue<std::pair<int, int>> q;

    int n = s.length();
    std::vector<int> c(n + offset, 0);
    auto lowbit = [&](int x) { return x & (-x); };
    auto add    = [&](int pos, int v) {
        for (int i = pos + offset; i < n + offset; i += lowbit(i)) c[i] += v;
    };
    auto sum = [&](int pos) {
        int res = 0;
        for (int i = pos + offset; i >= offset; i -= lowbit(i)) res += c[i];
        return res;
    };

    for (auto [i, c] : s | std::views::reverse | std::views::enumerate) q.push({c - '0' + i + 1 - n, n - 1 - i});

    for (auto i : std::views::iota(0)) {
        if (q.empty()) break;
        auto [v, p] = q.top();
        q.pop();
        std::cout << (i <= p ? v + i : v + i - sum(n - 1) + sum(p));
        add(p, 1);
    }
    std::cout << "\n";
    // std::cerr << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(0);

    int t;
    std::cin >> t;
    for (auto i : std::views::iota(0, t)) solve();
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int power(int A, int expo)
{
    if (expo == 0)
        return 1;
    int res = power(A, expo / 2);
    if (expo % 2)
        return res * res * A;
    else
        return res * res;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int factorial(int x)
{
    if (x == 1 || x == 0)
        return 1;
    return (x * factorial(x - 1));
}
class UnionFind{
    private: vector<int> parent,rank;
    public:
        UnionFind(int n){
            rank.assign(n,0);
            parent.assign(n,0);
            iota(parent.begin(),parent.end(),0);
        }
        int find(int x) {
            if(parent[x] == x)
                return x;
            
            return parent[x] = find(parent[x]);
        }

    void UnionSet(int x, int y) {
        int x_parent = find(x);
        int y_parent = find(y);

        if(rank[x_parent] > rank[y_parent]) {
            parent[y_parent] = x_parent;
        } else if(rank[x_parent] < rank[y_parent]) {
            parent[x_parent] = y_parent;
        } else {
            parent[x_parent] = y_parent;
            rank[y_parent]++;
        }
    }
};

int lcm(int a, int b) {
    return (a / gcd(a, b)) * b;
}

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

void solve() {
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=1;i<n;i++){
    int x=min(v[i],v[i-1]);
    v[i-1]-=x;
    v[i]-=x;
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(v[i]>0) cnt++;
  }
  if(cnt>1){
    cout<<"No\n";
  }
  else{
    cout<<"Yes\n";
  }
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;

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

        for (int i = n - 2; i > 0; i--)
        {
            int x = min(v[i], v[i - 1]);
            while (v[i] > v[i + 1])
            {
                v[i] -= x;
                v[i - 1] -= x;
            }
        }
        if (v[0] <= v[1])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;

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

        bool flag = true;

        for (int i = n - 2; i > 0; i--)
        {
            int x = min(v[i], v[i - 1]);
            while (v[i] > v[i + 1])
            {
                if (x == 0)
                {
                    flag = false;
                    break;
                }
                v[i] -= x;
                v[i - 1] -= x;
            }
            if (!flag)
                break;
        }
        if (!flag)
            cout << "no" << endl;
        if (v[0] <= v[1])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;

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

        bool flag = true;

        for (int i = n - 2; i > 0; i--)
        {
            int x = min(v[i], v[i - 1]);
            while (v[i] > v[i + 1])
            {
                if (x == 0)
                {
                    flag = false;
                    break;
                }
                v[i] -= x;
                v[i - 1] -= x;
            }
            if (!flag)
                break;
        }
        if (!flag)
            cout << "no" << endl;
        if (v[0] <= v[1])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;

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

        bool flag = true;

        for (int i = n - 2; i > 0; i--)
        {
            int x = min(v[i], v[i - 1]);
            if (v[i] > v[i + 1])
            {
                if (x == 0)
                {
                    flag = false;
                    break;
                }
                int y = (v[i] - v[i + 1]) / x;
                if ((v[i] - v[i + 1]) % x != 0)
                    y++;

                v[i] -= y * x;
                v[i - 1] -= y * x;
            }
            if (!flag)
                break;
        }
        if (!flag)
            cout << "no" << endl;
        if (v[0] <= v[1])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}
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;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;

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

        bool flag = true;

        for (int i = n - 2; i > 0; i--)
        {
            int x = min(v[i], v[i - 1]);
            if (v[i] > v[i + 1])
            {
                if (x == 0)
                {
                    flag = false;
                    break;
                }
                int y = (v[i] - v[i + 1]) / x;
                if ((v[i] - v[i + 1]) % x != 0)
                    y++;

                v[i] -= y * x;
                v[i - 1] -= y * x;
            }
            if (!flag)
                break;
        }
        if (!flag)
            cout << "no" << endl;
        if (v[0] <= v[1])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;

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

        bool flag = true;
        for (int i = 0; i < n - 1; i++)
        {
            if (v[i] > v[i + 1])
            {
                flag = false;
                break;
            }

            v[i + 1] -= v[i];
            v[i] = 0;
        }

        if (flag)
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;

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

        for (int i = n - 2; i > 0; i--)
        {
            int x = min(v[i], v[i - 1]);
            while (v[i] > v[i + 1])
            {
                v[i] -= x;
                v[i - 1] -= x;
            }
        }
        if (v[0] <= v[1])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

using namespace std;

void inline solve() {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int mask = 1 << 30; mask > 0; mask >>= 1) {
        // cout << "A " << a << ' ' << b << ' ' << c << ' ' << mask << '\n';
        if ((l & mask) == (r & mask)) {
            a |= (l & mask);
            b |= (l & mask);
            c |= (l & mask);
        } else {
            a |= mask;
            b |= mask-2;
            c |= mask-1;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
    cout << (a ^ b) + (a ^ c) + (b ^ c) << '\n';
}

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

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

    return 0;
}

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

using namespace std;

void inline solve() {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int mask = 1 << 30; mask > 0; mask >>= 1) {
        // cout << "A " << a << ' ' << b << ' ' << c << ' ' << mask << '\n';
        if ((l & mask) == (r & mask)) {
            a |= (l & mask);
            b |= (l & mask);
            c |= (l & mask);
        } else {
            a |= mask;
            b |= mask-2;
            c |= mask-1;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
    // cout << (a ^ b) + (a ^ c) + (b ^ c) << '\n';
}

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

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

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

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

using namespace std;

void inline solve() {
    int l, r;
    cin >> l >> r;
    int a = l;
    int b = 0;
    int c = 0;
    for (int i = 30; i >= 0; --i) {
        if (a & (1 << i)) continue;
        if ((b | (1 << i)) > r) continue;
        b |= 1 << i;
    }
    if (b < l) b = l+1;
    for (int i = 30; i >= 0; --i) {
        if (b & (1 << i)) continue;
        if ((c | (1 << i)) > r) continue;
        c |= 1 << i;
    }
    if (c < l) c = l;
    while (c == a || c == b) ++c;
    cout << a << ' ' << b << ' ' << c << '\n';
}

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

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

    return 0;
}

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

using namespace std;

void inline solve() {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int mask = 1 << 30; mask > 0; mask >>= 1) {
        // cout << "A " << a << ' ' << b << ' ' << c << ' ' << mask << '\n';
        if ((l & mask) == (r & mask)) {
            a |= (l & mask);
            b |= (l & mask);
            c |= (l & mask);
        } else {
            a |= mask;
            b |= mask-2;
            c |= mask-1;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
    cout << (a ^ b) + (a ^ c) + (b ^ c) << '\n';
}

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

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

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

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

using namespace std;

void inline solve() {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int mask = 1 << 30; mask > 0; mask >>= 1) {
        // cout << "A " << a << ' ' << b << ' ' << c << ' ' << mask << '\n';
        if ((l & mask) == (r & mask)) {
            a |= (l & mask);
            b |= (l & mask);
            c |= (l & mask);
        } else {
            a |= mask;
            b |= mask-2;
            c |= mask-1;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
    // cout << (a ^ b) + (a ^ c) + (b ^ c) << '\n';
}

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

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

    return 0;
}

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

using namespace std;

void inline solve() {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int mask = 1 << 30; mask > 0; mask >>= 1) {
        // cout << "A " << a << ' ' << b << ' ' << c << ' ' << mask << '\n';
        if ((l & mask) == (r & mask)) {
            a |= (l & mask);
            b |= (l & mask);
            c |= (l & mask);
        } else {
            a |= mask;
            b |= mask-1;
            if (b - 1 >= l) c = b-1;
            else c = a + 1;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
    // cout << (a ^ b) + (a ^ c) + (b ^ c) << '\n';
}

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

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

    return 0;
}