ShaysXIA/CodeInsightBench huggingface dataset:
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;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define int long long int
#define ul unsigned long long
#define dec greater<int>()
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

void solve()
{
    int l, r;
    cin >> l >> r;
    int a=-1,b=-1,mx=0,mn=99;
    for(int i=l; i<min(100000000LL,r); i++)
    {
        int xx = __builtin_popcount(i);
        if(xx<mn)
        {
            mn=xx;
            a=i;
        }
        if(xx>=mx)
        {
            mx=xx;
            b=i;
        }
        //cout<<xx<<'\n';
    }
    cout<<a<<" "<<b<<" "<<r<<'\n';
}

signed main()
{
    fast;
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}

/*You need to learn from the problem you solved.*/
/*If you got it slow, why? If you got WA, why?*/
/*What can you do to prevent it in the future?*/
/*Did you miss a critical observation?*/
/*What path of thinking would've led you there? */

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define int long long int
#define ul unsigned long long
#define dec greater<int>()
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

void solve()
{
    int l, r;
    cin >> l >> r;
    //int k = 31-__builtin_clz(l ^ r);//count leading zeros/find MSB index.
    int k=log2(l^r);//find MSB index
    //cout<<kk<<'\n';
    //cout<<k<<'\n';
    int a=(l | ((1<<k)-1));
    int b=a+1;
    int c=(a==l?r : l);
    cout<<a<<" "<<b<<' '<<c<<'\n';
}
signed main()
{
    fast;
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}

/*You need to learn from the problem you solved.*/
/*If you got it slow, why? If you got WA, why?*/
/*What can you do to prevent it in the future?*/
/*Did you miss a critical observation?*/
/*What path of thinking would've led you there? */
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define dec greater<int>()
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
void solve()
{
    int n,l,r,sum=0;
    cin>>n>>l>>r;
    vector<int>v(n);
    for(auto &i : v)cin>>i;
    sort(all(v));
    int limit=r-l+1;
    for(int i=0; i<limit; i++)sum+=v[i];
    cout<<sum<<'\n';
    
}
 
signed main()
{
    fast;    
    int t=1;
    cin>>t;
    while(t--)
      solve();
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define dec greater<int>()
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
void solve()
{
    int n,l,r,sum=0;
    cin>>n>>l>>r;
    vector<int>v(n),a;
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        if(i>=l-1 && i<r)
        {
            sum += v[i];
            a.push_back(v[i]);
        }
    }
    sort(v.begin(),v.begin()+l-1);
    sort(all(a),dec);
    int tmp=sum,res=sum;
    for(int i=0; i<l-1; i++)
    {
        tmp -= a[i];
        tmp += v[i];
        res=min(res,tmp);
    }
    sort(v.begin()+r,v.end());
    tmp=sum;
    for(int i=0; i<n-r; i++)
    {
        tmp-=a[i];
        tmp+=v[i+r];
        res=min(res,tmp);
    }
    cout<<res<<'\n';
}
 
signed main()
{
    fast;    
    int t=1;
    cin>>t;
    while(t--)
      solve();
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define dec greater<int>()
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
void solve()
{
    int n,l,r,sum=0;
    cin>>n>>l>>r;
    vector<int>v(n);
    for(auto &i : v)cin>>i;
    sort(all(v));
    int limit=r-l+1;
    for(int i=0; i<limit; i++)sum+=v[i];
    cout<<sum<<'\n';
    
}
 
signed main()
{
    fast;    
    int t=1;
    cin>>t;
    while(t--)
      solve();
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define dec greater<int>()
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
void solve()
{
    int n,l,r,sum=0;
    cin>>n>>l>>r;
    vector<int>v(n),a;
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        if(i>=l-1 && i<r)
        {
            sum += v[i];
            a.push_back(v[i]);
        }
    }
    sort(v.begin(),v.begin()+l-1);
    sort(all(a),dec);
    int tmp=sum,res=sum;
    for(int i=0; i<l-1; i++)
    {
        tmp -= a[i];
        tmp += v[i];
        res=min(res,tmp);
    }
    sort(v.begin()+r,v.end());
    tmp=sum;
    for(int i=0; i<n-r; i++)
    {
        tmp-=a[i];
        tmp+=v[i+r];
        res=min(res,tmp);
    }
    cout<<res<<'\n';
}
 
signed main()
{
    fast;    
    int t=1;
    cin>>t;
    while(t--)
      solve();
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define dec greater<int>()
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
void solve()
{
    int n,l,r,sum=0;
    cin>>n>>l>>r;
    vector<int>v(n),a;
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        if(i>=l-1 && i<r)
        {
            sum += v[i];
            a.push_back(v[i]);
        }
    }
    sort(v.begin(),v.begin()+l-1);
    sort(all(a),dec);
    int tmp=sum,res=sum;
    for(int i=0; i<min(l-1,(long long)a.size()); i++)
    {
        tmp -= a[i];
        tmp += v[i];
        res=min(res,tmp);
    }
    sort(v.begin()+r,v.end());
    tmp=sum;
    int bound=min(n-r,(long long)a.size());
    for(int i=0; i<bound; i++)
    {
        tmp-=a[i];
        tmp+=v[i+r];
        res=min(res,tmp);
    }
    cout<<res<<'\n';
}
 
signed main()
{
    fast;    
    int t=1;
    cin>>t;
    while(t--)
      solve();
}
Problem: 2050D - Digital string maximization
Language: Python 3

Previous submission (verdict: Time limit exceeded on test 3):
# cook your dish here
testcases = int(input())
for testcase in range(testcases):
    string = str(input())
    s = [ch for ch in string]
    ans = []
    # print(s)
    for index in range(0, len(s)):
        found = False
        dig = int(s[index])
        for new_dig in range(8, dig, -1):
            for num in range(new_dig + 1, 10):
                ind = num - new_dig + index
                if ind >= 0 and ind < len(s) and s[ind] == str(num):
                    ans.append(str(new_dig))
                    s = s[:index] + [ans[-1]] + s[index:ind] + s[ind + 1:]
                    # print(s)
                    found = True
                    break 
            if found:
                break 
        if not found:
            ans.append(s[index])
    print("".join(ans))

Submission (verdict: Time limit exceeded on test 3):
# cook your dish here
testcases = int(input())
for testcase in range(testcases):
    string = str(input())
    s = [ch for ch in string]
    ans = []
    for index in range(0, len(s)):
        found = False
        dig = int(s[index])
        for new_dig in range(8, dig, -1):
            for num in range(new_dig + 1, 10):
                ind = num - new_dig + index
                if ind >= 0 and ind < len(s) and s[ind] == str(num):
                    ans.append(str(new_dig))
                    for i in range(ind, index, -1):
                        s[i] = s[i - 1]
                    s[index] = ans[-1]
                    found = True
                    break 
            if found:
                break 
        if not found:
            ans.append(s[index])
    print("".join(ans))
Problem: 2050D - Digital string maximization
Language: Python 3

Previous submission (verdict: Time limit exceeded on test 3):
# cook your dish here
testcases = int(input())
for testcase in range(testcases):
    string = str(input())
    s = [ch for ch in string]
    ans = []
    for index in range(0, len(s)):
        found = False
        dig = int(s[index])
        for new_dig in range(8, dig, -1):
            for num in range(new_dig + 1, 10):
                ind = num - new_dig + index
                if ind >= 0 and ind < len(s) and s[ind] == str(num):
                    ans.append(str(new_dig))
                    for i in range(ind, index, -1):
                        s[i] = s[i - 1]
                    s[index] = ans[-1]
                    found = True
                    break 
            if found:
                break 
        if not found:
            ans.append(s[index])
    print("".join(ans))

Submission (verdict: Accepted):
# cook your dish here
testcases = int(input())
for testcase in range(testcases):
    s = str(input())
    digits = []
    for d in s:
        digits.append(int(d))
    for i in range(len(s)):
        curr = digits[i]
        idx = -1
        maxx = curr
        limit = min(len(s), i + 9 - curr)
        for j in range(i + 1, limit):
            if maxx < digits[j] - (j - i):
                idx = j 
                maxx = digits[j] - (j - i)
        if idx != -1:
            for k in range(idx, i, -1):
                digits[k] = digits[k - 1]
        digits[i] = maxx
    ans = [str(d) for d in digits]
    print("".join(ans))
Problem: 2050D - Digital string maximization
Language: Python 3


Submission (verdict: Time limit exceeded on test 3):
# cook your dish here
testcases = int(input())
for testcase in range(testcases):
    string = str(input())
    s = [ch for ch in string]
    ans = []
    # print(s)
    for index in range(0, len(s)):
        found = False
        dig = int(s[index])
        for new_dig in range(8, dig, -1):
            for num in range(new_dig + 1, 10):
                ind = num - new_dig + index
                if ind >= 0 and ind < len(s) and s[ind] == str(num):
                    ans.append(str(new_dig))
                    s = s[:index] + [ans[-1]] + s[index:ind] + s[ind + 1:]
                    # print(s)
                    found = True
                    break 
            if found:
                break 
        if not found:
            ans.append(s[index])
    print("".join(ans))
Problem: 2050E - Three Strings
Language: Python 3

Previous submission (verdict: Running on test 1):
testcases = int(input())
for testcase in range(testcases):
    a = str(input())
    b = str(input())
    c = str(input())
    dp = [[-1 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
    def solve(ptr1, ptr2, a, b, c, dp)-> int:
        if ptr1 == len(a) and ptr2 == len(b):
            return 0
        minChange = 2001
        usingA, usingB = 2001, 2001
        if ptr1 < len(a):
            usingA = solve(ptr1 + 1, ptr2, a, b, c, dp)
            if a[ptr1] != c[ptr1 + ptr2]:
                usingA += 1
        if ptr2 < len(b):
            usingB = solve(ptr1, ptr2 + 1, a, b, c, dp)
            if b[ptr2] != c[ptr1 + ptr2]:
                usingB += 1 
        dp[ptr1][ptr2] = min(usingA, usingB)
        return dp[ptr1][ptr2]
    minChange = solve(0, 0, a, b, c, dp)
    print(minChange)
    

Submission (verdict: Runtime error on test 16):
testcases = int(input())
for testcase in range(testcases):
    a = str(input())
    b = str(input())
    c = str(input())
    dp = [[-1 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
    def solve(ptr1, ptr2, a, b, c, dp)-> int:
        if ptr1 == len(a) and ptr2 == len(b):
            return 0
        if dp[ptr1][ptr2] != -1:
            return dp[ptr1][ptr2]
        minChange = 2001
        usingA, usingB = 2001, 2001
        if ptr1 < len(a):
            usingA = solve(ptr1 + 1, ptr2, a, b, c, dp)
            if a[ptr1] != c[ptr1 + ptr2]:
                usingA += 1
        if ptr2 < len(b):
            usingB = solve(ptr1, ptr2 + 1, a, b, c, dp)
            if b[ptr2] != c[ptr1 + ptr2]:
                usingB += 1 
        dp[ptr1][ptr2] = min(usingA, usingB)
        return dp[ptr1][ptr2]
    minChange = solve(0, 0, a, b, c, dp)
    print(minChange)
Problem: 2050E - Three Strings
Language: Python 3


Submission (verdict: Runtime error on test 1):
def solve(ptr1: int, ptr2: int, a: str, b: str, c: str, dp: list[list[int]])-> int:
    if ptr1 == len(a) and ptr2 == len(b):
        return 0
    minChange = 2001
    usingA, usingB = 2001, 2001
    if ptr1 < len(a):
        usingA = solve(ptr1 + 1, ptr2, a, b, c, dp)
        if a[ptr1] != c[ptr1 + ptr2]:
            usingA += 1
    if ptr2 < len(b):
        usingB = solve(ptr1, ptr2 + 1, a, b, c, dp)
        if b[ptr2] != c[ptr1 + ptr2]:
            usingB += 1 
    dp[ptr1][ptr2] = min(usingA, usingB)
    return dp[ptr1][ptr2]

testcases = int(input())
for testcase in range(testcases):
    a = str(input())
    b = str(input())
    c = str(input())
    dp = [[-1 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
    minChange = solve(0, 0, a, b, c, dp)
    print(minChange)
Problem: 2050E - Three Strings
Language: Python 3

Previous submission (verdict: Runtime error on test 1):
def solve(ptr1: int, ptr2: int, a: str, b: str, c: str, dp: list[list[int]])-> int:
    if ptr1 == len(a) and ptr2 == len(b):
        return 0
    minChange = 2001
    usingA, usingB = 2001, 2001
    if ptr1 < len(a):
        usingA = solve(ptr1 + 1, ptr2, a, b, c, dp)
        if a[ptr1] != c[ptr1 + ptr2]:
            usingA += 1
    if ptr2 < len(b):
        usingB = solve(ptr1, ptr2 + 1, a, b, c, dp)
        if b[ptr2] != c[ptr1 + ptr2]:
            usingB += 1 
    dp[ptr1][ptr2] = min(usingA, usingB)
    return dp[ptr1][ptr2]

testcases = int(input())
for testcase in range(testcases):
    a = str(input())
    b = str(input())
    c = str(input())
    dp = [[-1 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
    minChange = solve(0, 0, a, b, c, dp)
    print(minChange)

Submission (verdict: Running on test 1):
testcases = int(input())
for testcase in range(testcases):
    a = str(input())
    b = str(input())
    c = str(input())
    dp = [[-1 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
    def solve(ptr1, ptr2, a, b, c, dp)-> int:
        if ptr1 == len(a) and ptr2 == len(b):
            return 0
        minChange = 2001
        usingA, usingB = 2001, 2001
        if ptr1 < len(a):
            usingA = solve(ptr1 + 1, ptr2, a, b, c, dp)
            if a[ptr1] != c[ptr1 + ptr2]:
                usingA += 1
        if ptr2 < len(b):
            usingB = solve(ptr1, ptr2 + 1, a, b, c, dp)
            if b[ptr2] != c[ptr1 + ptr2]:
                usingB += 1 
        dp[ptr1][ptr2] = min(usingA, usingB)
        return dp[ptr1][ptr2]
    minChange = solve(0, 0, a, b, c, dp)
    print(minChange)
Problem: 2050E - Three Strings
Language: Python 3

Previous submission (verdict: Runtime error on test 16):
testcases = int(input())
for testcase in range(testcases):
    a = str(input())
    b = str(input())
    c = str(input())
    dp = [[-1 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
    def solve(ptr1, ptr2, a, b, c, dp)-> int:
        if ptr1 == len(a) and ptr2 == len(b):
            return 0
        if dp[ptr1][ptr2] != -1:
            return dp[ptr1][ptr2]
        minChange = 2001
        usingA, usingB = 2001, 2001
        if ptr1 < len(a):
            usingA = solve(ptr1 + 1, ptr2, a, b, c, dp)
            if a[ptr1] != c[ptr1 + ptr2]:
                usingA += 1
        if ptr2 < len(b):
            usingB = solve(ptr1, ptr2 + 1, a, b, c, dp)
            if b[ptr2] != c[ptr1 + ptr2]:
                usingB += 1 
        dp[ptr1][ptr2] = min(usingA, usingB)
        return dp[ptr1][ptr2]
    minChange = solve(0, 0, a, b, c, dp)
    print(minChange)
    

Submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**6)
testcases = int(input())
for testcase in range(testcases):
    a = str(input())
    b = str(input())
    c = str(input())
    dp = [[-1 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
    def solve(ptr1, ptr2, a, b, c, dp)-> int:
        if ptr1 == len(a) and ptr2 == len(b):
            return 0
        if dp[ptr1][ptr2] != -1:
            return dp[ptr1][ptr2]
        minChange = 2001
        usingA, usingB = 2001, 2001
        if ptr1 < len(a):
            usingA = solve(ptr1 + 1, ptr2, a, b, c, dp)
            if a[ptr1] != c[ptr1 + ptr2]:
                usingA += 1
        if ptr2 < len(b):
            usingB = solve(ptr1, ptr2 + 1, a, b, c, dp)
            if b[ptr2] != c[ptr1 + ptr2]:
                usingB += 1 
        dp[ptr1][ptr2] = min(usingA, usingB)
        return dp[ptr1][ptr2]
    minChange = solve(0, 0, a, b, c, dp)
    print(minChange)
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define vi vector<ll>
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umii unordered_map<ll,ll,custom_hash>
#define mii map<ll,ll>
#define FOR(vec) for(auto &x : vec) cin >> x;
#define FOR1(vec) for(int i = 1 ; i<= vec.size()-1; i++) cin >> vec[i];

const int M = 998244353;
const int N = 2e5+10;
const int maxint = 2e9 + 1;

// Binary Exponentiation
// int binExp(int a, int b){
// 	int ans = 1;
// 	while(b){
// 		if(b&1){
// 			ans = (ans*1LL*a)%M;
// 		}
// 		a = (a*1LL*a)%M;
// 		b>>=1;
// 	}
// 	return ans;
// }

// DSU CODE

// int parent[N];
// int size[N];
// void make(int v, int parent[], int size[]){
//     parent[v] = v;
//     size[v] = 1;
// }

// int find(int v, int parent[]){
//     if(v == parent[v]) return v;
//     return parent[v] = find(parent[v], parent);
// } // O(alpha(n)) time complexity, grows very slowly

// void Union(int a, int b, int parent[], int size[]){
//     a = find(a, parent);
//     b = find(b, parent);
//     if(a != b){
//         if(size[a] < size[b]) swap(a, b);
//         parent[b] = a;
//         size[a] += size[b];
//     }
// }

int r=0, l=0;
int dp[32][2];

ll func(int bit,int prevNum){
    if(bit == -1){
        if(prevNum != l && prevNum != r) return prevNum;
        else return 0;
    } 

    int l_bit = (l>>bit);
    int r_bit = (r>>bit);

    ll ans1 = 0, ans2 = 0;
    if( ((prevNum<<1)+1) <= r_bit  ){
        if(dp[bit][1] != -1) ans1 = dp[bit][1];
        else ans1 = func(bit - 1, (prevNum<<1)+1);
        dp[bit][1] = ans1;
        // if(ans1 == r || ans1 == l) ans1 = 0; 
    }
    if( ((prevNum<<1)) >= l_bit  ){
        if(dp[bit][0] != -1) ans2 = dp[bit][0];
        else ans2 = func(bit - 1, (prevNum<<1));
        dp[bit][0] = ans2;
        // if(ans2 == r || ans2 == l) ans2 = 0; 
    }

    ll ans = 0;
    if(ans1 && ans2){
        if(((ans1^l)+(ans1^r)) > ((ans2^l)+(ans2^r)) ){
            ans = ans1;
        }else ans = ans2;
    }else ans = max(ans1, ans2);

    return ans;
    // cout<<bit<<" "<<prevNum<<" "<<(prevNum<<1)<<" currbits: "<<l_bit<<" "<<r_bit<<endl;
    // return max(ans1, ans2);
}

void solve(){
    memset(dp, -1, sizeof(dp));
    cin>>l>>r;
    int max_bits = log2(r);
    cout<<l<<" "<<func(max_bits , 0)<<" "<<r<<endl;
}	



int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t;
	cin>>t;
	while(t--){
		solve();
	}	
}
Problem: 2062C - Cirno and Operations
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
#define pii pair<int,int>

const int M = 998244353;
const int N = 2e5+10;
const int maxint = 2e9 + 1;

int binExp(int a, int b){
	int ans = 1;
	while(b){
		if(b&1){
			ans = (ans*1LL*a)%M;
		}
		a = (a*1LL*a)%M;
		b>>=1;
	}
	return ans;
}


void solve(){
	int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    int sum = accumulate(a.begin(), a.end(), 0);
    while(a.size() > 1){
        vector<int> newA(a.size()-1);
        for (int i = 0; i < a.size() -1 ; ++i)
        {
            newA[i] = a[i+1] - a[i];
        }
        sum = max(sum, abs(accumulate(newA.begin(), newA.end(), 0)));

        a = newA;
    }

    cout<<sum<<endl;
}	



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





Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>

const int M = 998244353;
const int N = 2e5+10;
const int maxint = 2e9 + 1;

int binExp(int a, int b){
	int ans = 1;
	while(b){
		if(b&1){
			ans = (ans*1LL*a)%M;
		}
		a = (a*1LL*a)%M;
		b>>=1;
	}
	return ans;
}


void solve(){
	int n;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    ll sum = accumulate(a.begin(), a.end(), 0);
    while(a.size() > 1){
        vector<ll> newA(a.size()-1);
        for (int i = 0; i < a.size() -1 ; ++i)
        {
            newA[i] = a[i+1] - a[i];
        }
        sum = max(sum, 1LL*abs(accumulate(newA.begin(), newA.end(), 0)));

        a = newA;
    }

    cout<<sum<<endl;
}	



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