ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
// #include <iostream>        // For input/output
// #include <vector>          // For using std::vector
// #include <tuple>           // For using std::tuple
// #include <algorithm>       // For sorting and other algorithms
// #include <queue>           // For std::queue and std::priority_queue
// #include <unordered_map>   // For std::unordered_map
// #include <string>          // For std::string
// #include <cmath>           // For std::pow
// using namespace std;

// int main(){
//     cout<<"hello"<<"\n";
//     return 0;
// }





#include <bits/stdc++.h>
using namespace std;
int solve(int i, int j, int k, string &a, string &b, string &c, int& an, int& bn, int& cn){
    if(k==cn)return 0;
    if(i==an || j==bn){
        int ct=0;
        if(i==an){
            for(int g=j;g<bn;g++){
                if(b[g]!=c[k])ct++;
                k++;
            }
            if(k<cn)ct+=(cn-k-1);
        } else {
            for(int g=i;g<an;g++){
                if(a[g]!=c[k])ct++;
                k++;
            }
            if(k<cn)ct+=(cn-(k+1));
        }
        return ct;
    }
    int res=1e9;
    if(i<an){
        int cost = (a[i]!=c[k]) + solve(i+1,j,k+1,a,b,c,an,bn,cn);
        res = min(res,cost);
    }
    if(j<bn){
        int cost = (b[j]!=c[k]) + solve(i,j+1,k+1,a,b,c,an,bn,cn);
        res = min(res,cost);
    }
    return res;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t;cin >> t;
	while(t--){
	    string a,b,c;cin>>a>>b>>c;
	    int an=a.size(),bn=b.size(),cn=c.size();
	    cout<<solve(0,0,0,a,b,c,an,bn,cn)<<"\n";
	}
	return 0;
}

// 1
// 0
// 2
// 0
// 3
// 2
// 3
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

#define deb cout<<"#"<<endl;

#define pse system("pause");

using namespace std;

using i64=long long;

using f64=double;

using str=string;

using vint=vector<int>;

using pii=pair<int,int>;

constexpr int inf = 2e9;

constexpr i64 inf64 = 9e18;

constexpr int md = 1e9+7;

constexpr int N = 3e5+10;







void init() {



}



void solve(){

    int n;cin>>n;

    str s;cin>>s;

    s=' '+s;

    int x{},y{};

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

        if (s[i]=='s') x++;

        else if (s[i]=='p') y++;

    }



    if (x==0||y==0||(x==1&&s[n]=='p')||(y==1&&s[1]=='s')) {

        cout<<"YES"<<'\n';

    }

    else {

        cout<<"NO"<<'\n';

    }

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    //init();

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}

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

#define deb cout<<"#"<<endl;

#define pse system("pause");

using namespace std;

using i64=long long;

using f64=double;

using str=string;

using vint=vector<int>;

using pii=pair<int,int>;

constexpr int inf = 2e9;

constexpr i64 inf64 = 9e18;

constexpr int md = 1e9+7;

constexpr int N = 3e5+10;







void init() {



}



void solve(){

    int n;cin>>n;

    str s;cin>>s;

    s=' '+s;

    int x{},y{};

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

        if (s[i]=='s') x++;

        else if (s[i]=='p') y++;

    }



    if (x==0||y==0||(y==1&&s[n]=='p')||(x==1&&s[1]=='s')) {

        cout<<"YES"<<'\n';

    }

    else {

        cout<<"NO"<<'\n';

    }

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    //init();

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

#define deb cout<<"#"<<endl;

#define pse system("pause");

using namespace std;

using i64=long long;

using f64=double;

using str=string;

using vint=vector<int>;

using pii=pair<int,int>;

constexpr int inf = 2e9;

constexpr i64 inf64 = 9e18;

constexpr int md = 1e9+7;

constexpr int N = 3e5+10;







void init() {



}



void solve(){

    int n;cin>>n;

    str s;cin>>s;

    s=' '+s;

    int x{},y{};

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

        if (s[i]=='s') x++;

        else if (s[i]=='p') y++;

    }



    if (x==0||y==0||((x==1||y==1)&&s[1]=='s'&&s[n]=='p')) {

        cout<<"YES"<<'\n';

    }

    else {

        cout<<"NO"<<'\n';

    }

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    //init();

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}

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

#define deb cout<<"#"<<endl;

#define pse system("pause");

using namespace std;

using i64=long long;

using f64=double;

using str=string;

using vint=vector<int>;

using pii=pair<int,int>;

constexpr int inf = 2e9;

constexpr i64 inf64 = 9e18;

constexpr int md = 1e9+7;

constexpr int N = 3e5+10;







void init() {



}



void solve(){

    int n;cin>>n;

    str s;cin>>s;

    s=' '+s;

    int x{},y{};

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

        if (s[i]=='s') x++;

        else if (s[i]=='p') y++;

    }



    if (x==0||y==0||(x==1&&s[n]=='p')||(y==1&&s[1]=='s')) {

        cout<<"YES"<<'\n';

    }

    else {

        cout<<"NO"<<'\n';

    }

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    //init();

    int _=1;

    cin>>_;

    while(_--){

        solve();

    }

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


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

#define deb cout<<"#"<<endl;

#define pse system("pause");

using namespace std;

using i64=long long;

using f64=double;

using str=string;

using vint=vector<int>;

using pii=pair<int,int>;

constexpr int inf = 2e9;

constexpr i64 inf64 = 9e18;

constexpr int md = 1e9+7;

constexpr int N = 3e5+10;







void init() {



}



void solve(){

    int n;cin>>n;

    str s;cin>>s;

    s=' '+s;

    int x{},y{};

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

        if (s[i]=='s') x++;

        else if (s[i]=='p') y++;

    }



    if (x==0||y==0||((x==1||y==1)&&s[1]=='s'&&s[n]=='p')) {

        cout<<"YES"<<'\n';

    }

    else {

        cout<<"NO"<<'\n';

    }

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    //init();

    int _=1;

    cin>>_;

    while(_--){

        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;
using ll = long long;

const int N = 2e5+5;
int a[N];
int b[N];

void _main(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i],ans+=a[i],b[i]=0;
	for(;n!=1;n--){
		ll sum=0;
		for(int j=2;j<=n;j++)
			b[j-1]=a[j]-a[j-1],sum+=b[j-1];
		for(int j=1;j<=n-1;j++)
			a[j]=b[j];
		ans=max(ans,max(sum,-sum));
	}
	cout<<ans<<"\n";
	return;
}
int main(){
	int t;
	cin>>t;
	while(t--)
		_main();
	return 0;
}

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

const int N = 2e5+5;
int a[N];
int b[N];

void _main(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i],ans+=a[i],b[i]=0;
	for(;n>=1;n--){
		ll sum=0;
		for(int j=2;j<=n;j++)
			b[j-1]=a[j]-a[j-1],sum+=b[j-1];
		for(int j=1;j<=n-1;j++)
			a[j]=b[j];
		ans=max(ans,max(sum,-sum));
	}
	cout<<ans<<"\n";
	return;
}
int main(){
	int t;
	cin>>t;
	while(t--)
		_main();
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

const int N = 2e5+5;
int a[N];
int b[N];

void _main(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i],ans+=a[i],b[i]=0;
	for(;n>=1;n--){
		ll sum=0;
		for(int j=2;j<=n;j++)
			b[j-1]=a[j]-a[j-1],sum+=b[j-1];
		for(int j=1;j<=n-1;j++)
			a[j]=b[j];
		ans=max(ans,max(sum,-sum));
	}
	cout<<ans<<"\n";
	return;
}
int main(){
	int t;
	cin>>t;
	while(t--)
		_main();
	return 0;
}

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

const int N = 2e5+5;
ll a[N];
ll b[N];

void _main(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i],ans+=a[i],b[i]=0;
	for(;n!=1;n--){
		ll sum=0;
		for(int j=2;j<=n;j++)
			b[j-1]=a[j]-a[j-1],sum+=b[j-1];
		for(int j=1;j<=n-1;j++)
			a[j]=b[j];
		ans=max(ans,max(sum,-sum));
	}
	cout<<ans<<"\n";
	return;
}
int main(){
	int t;
	cin>>t;
	while(t--)
		_main();
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

const int N = 2e5+5;
int a[N];
int b[N];

void _main(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i],ans+=a[i],b[i]=0;
	for(;n!=1;n--){
		ll sum=0;
		for(int j=2;j<=n;j++)
			b[j-1]=a[j]-a[j-1],sum+=b[j-1];
		for(int j=1;j<=n-1;j++)
			a[j]=b[j];
		ans=max(ans,max(sum,-sum));
	}
	cout<<ans<<"\n";
	return;
}
int main(){
	int t;
	cin>>t;
	while(t--)
		_main();
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

const int N = 100010;
int a[N];
int main(){
    int t; scanf("%d",&t);
    while(t--){
        int n,l,r,len; scanf("%d%d%d",&n,&l,&r);
        len = r - l + 1;
        for(int i = 0;i < n;i++) scanf("%d",&a[i]);
        sort(a,a + n);
        int ans = 0;
        for(int i = 0;i < len;i++) ans += a[i];
        printf("%d\n",ans);
    }
    return 0;
}

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



using namespace std;



const int N = 100010;

int a[N],b[N];

int main(){

    int t; scanf("%d",&t);

    while(t--){

        int n,l,r,len; scanf("%d%d%d",&n,&l,&r);

        len = r - l + 1;

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

            scanf("%d",&a[i]);

            b[i] = a[i];

        }

        sort(a,a + r);

        int ans = 0,tmp = 0;

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

        sort(b + l - 1,b + n);

        for(int i = l - 1;i < l - 1 + len;i++) ans += b[i];

        ans = min(ans,tmp);

        printf("%d\n",ans);

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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



using namespace std;



const int N = 100010;

int a[N],b[N];

int main(){

    int t; scanf("%d",&t);

    while(t--){

        int n,l,r,len; scanf("%d%d%d",&n,&l,&r);

        len = r - l + 1;

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

            scanf("%d",&a[i]);

            b[i] = a[i];

        }

        sort(a,a + r);

        int ans = 0,tmp = 0;

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

        sort(b + l - 1,b + n);

        for(int i = l - 1;i < l - 1 + len;i++) ans += b[i];

        ans = min(ans,tmp);

        printf("%d\n",ans);

    }

    return 0;

}

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

using namespace std;

const int N = 100010;
int a[N],b[N];
int main(){
    int t; scanf("%d",&t);
    while(t--){
        int n,l,r,len; scanf("%d%d%d",&n,&l,&r);
        len = r - l + 1;
        for(int i = 0;i < n;i++){
            scanf("%d",&a[i]);
            b[i] = a[i];
        }
        sort(a,a + r);
        long long ans = 0,tmp = 0;
        for(int i = 0;i < len;i++) tmp += a[i];
        sort(b + l - 1,b + n);
        for(int i = l - 1;i < l - 1 + len;i++) ans += b[i];
        ans = min(ans,tmp);
        printf("%lld\n",ans);
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

const int N = 100010;
int a[N];
int main(){
    int t; scanf("%d",&t);
    while(t--){
        int n,l,r,len; scanf("%d%d%d",&n,&l,&r);
        len = r - l + 1;
        for(int i = 0;i < n;i++) scanf("%d",&a[i]);
        sort(a,a + n);
        int ans = 0;
        for(int i = 0;i < len;i++) ans += a[i];
        printf("%d\n",ans);
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define f(a, n) for (int i = a; i < n; i++)
using namespace std;

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

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

        int prev = arr[0];
        int curr = arr[1];
        bool ispos = true;
        for (int i = 2; i < n; i++)
        {
            if (abs(curr - prev) > arr[i])
            {
                ispos = false;
                break;
            }
            int temp = min(curr,prev);
            prev = arr[i - 1] - temp;
            curr = arr[i];
        }

        if (ispos)
            cout << "YES" <<endl;
        else
            cout << "NO" <<endl;
    }
   
};

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define f(a, n) for (int i = a; i < n; i++)
using namespace std;

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

        int n;
        cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++)
        {
            cin >> arr[i];
        }
        bool ispos = true;
        if (n < 4)
        {
            for (int i = 1; i < n; i++)
            {
                int tp = min(arr[i], arr[i - 1]);
                arr[i] = arr[i] - tp;
                arr[i - 1] = arr[i - 1] - tp;
            }

            for (int i = 0; i < n - 1; i++)
            {
                if (arr[i + 1] < arr[i])
                {
                    ispos = false;
                    break;
                }
            }
        }

        else
        {

            int prev = arr[0];
            int curr = arr[1];
            for (int i = 2; i < n; i++)
            {
                if (abs(curr - prev) > arr[i])
                {
                    ispos = false;
                    break;
                }
                int temp = min(curr, prev);
                prev = arr[i - 1] - temp;
                curr = arr[i];
            }
        }
        if (ispos)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
};
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define f(a, n) for (int i = a; i < n; i++)
using namespace std;

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

        int n;
        cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++)
        {
            cin >> arr[i];
        }
        bool ispos = true;
        if (n < 4)
        {
            for (int i = 1; i < n; i++)
            {
                int tp = min(arr[i], arr[i - 1]);
                arr[i] = arr[i] - tp;
                arr[i - 1] = arr[i - 1] - tp;
            }

            for (int i = 0; i < n - 1; i++)
            {
                if (arr[i + 1] < arr[i])
                {
                    ispos = false;
                    break;
                }
            }
        }

        else
        {

            int prev = arr[0];
            int curr = arr[1];
            for (int i = 2; i < n; i++)
            {
                if (abs(curr - prev) > arr[i])
                {
                    ispos = false;
                    break;
                }
                int temp = min(curr, prev);
                prev = arr[i - 1] - temp;
                curr = arr[i];
            }
        }
        if (ispos)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
};

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

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

        int n;
        cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++)
        {
            cin >> arr[i];
        }
        bool ispos = true;
        // if (n < 4)
        // {
        for (int i = 1; i < n; i++)
        {
            int tp = min(arr[i], arr[i - 1]);
            arr[i] = arr[i] - tp;
            arr[i - 1] = arr[i - 1] - tp;
        }

        for (int i = 0; i < n - 1; i++)
        {
            if (arr[i + 1] < arr[i])
            {
                ispos = false;
                break;
            }
        }
        // }

        // else
        // {

        //     int prev = arr[0];
        //     int curr = arr[1];
        //     for (int i = 2; i < n; i++)
        //     {
        //          int temp = min(curr, prev);
        //         if ( (curr-temp) > arr[i])
        //         {
        //             cout << "enter " << " " ;
        //             ispos = false;
        //             break;
        //         }

        //         prev = arr[i - 1] - temp;
        //         curr = arr[i];
        //     }
        // }
        if (ispos)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
};
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define f(a, n) for (int i = a; i < n; i++)
using namespace std;

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

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

        int prev = arr[0];
        int curr = arr[1];
        bool ispos = true;
        for (int i = 2; i < n; i++)
        {
            if (abs(curr - prev) > arr[i])
            {
                ispos = false;
                break;
            }
            int temp = min(curr,prev);
            prev = arr[i - 1] - temp;
            curr = arr[i];
        }

        if (ispos)
            cout << "YES" <<endl;
        else
            cout << "NO" <<endl;
    }
   
};
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

using namespace std;

int nproblems;
int n;
int k;
int tmp;
map<int, int> mp;

int main(){
        cin >> nproblems;
        for(int i = 0; i< nproblems; i++){
                cin >> n;
                cin >> k;
                for(int j = 0; j <n; j++){
                        cin >> tmp; //current element of array
                        if(mp.count(tmp)){ //if key is allready in map
                                mp[tmp]++; //increment count
                        } else {
                                mp[tmp] = 1; //or add to map w/ count 1
                        }
                }
                if(mp.empty()){
                        mp = {};
                        cout << 0 << "\n";
                        continue;
                }
                map<int, int>::iterator it = mp.begin();

                //find number with maximum occurences
                int maxkey;
                it = mp.begin();
                maxkey = it -> first;
                it++;
                while(it != mp.end()){
                        if(it -> second >= mp[maxkey]){ //chose last max so that we dont collide w. min
                                maxkey = it -> first;
                        }
                        it++;
                }
                // remove k least frequent numbers
                while (k > 0){
                        //find least frequent number:
                        it = mp.begin();
                        int minkey = it->first;
                        it++;
                        while(it != mp.end()){
                                if(it->second < mp[minkey]){
                                        minkey = it->first;
                                }
                                it++;
                        }
                        //now we have the smallest number of occurances
                        if(mp[minkey] <= k){ //if we have enough changes {k}
                                //change all of the least frequent # to the most frequent
                                mp[maxkey] += mp[minkey];
                                k = k-mp[minkey];
                                mp.erase(minkey);
                        } else { //we have less changes than the least frequent num
                                //so changes wont reduce the number of moves.
                                k = 0;
                        }

                }
                //do actual count of operations (# of distinct nums in list)
                cout << mp.size()<< "\n";
                mp = {}; //clear map at end of each loop
        }

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


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

#define log(x) cout << x << "\n"

using namespace std;
int n;
int l;
int r;
int t;
int sumsub(int a[], int l, int r);
void reversesub(int a[],int l,int r);
int sumvec(vector<int> v, int stop);

int main(){
        cin >> t;
        while ( t > 0){
                cin >> n >> l >> r;
                int a[n];
                for (int i= 0; i < n; i++){
                        cin >> a[i];
                }
                l--;
                vector<int> b(r, 0);

                //cout << "size: " << b.size() << " b: \n";
                for(int i = 0; i < b.size(); i++){
                        //cout << "i: " << i << ", b[i]: ";
                        b[i] = a[i];
                        //cout << b[i] << "\n";
                }
                //cout << "\n";
                int minsum = (int)1E8;
                if (!b.empty()){
                        sort(b.begin(), b.end());
                        minsum = min(minsum, sumvec(b, r-l));
                        //cout << "s1: " << sumvec(b, r-l) << "\n";
                }
                
                vector<int> c(n-l, 0);
                //cout << "size: " << c.size() <<", c: \n";
                for(int i = 0; i < c.size(); i++){
                        c[i] = a[l+i];
                        //cout <<"i: "<< i << "c[i]: " << c[i] << "\n";
                }
                //cout << "\n";
                
                if(!c.empty()){
                        sort(c.begin(), c.end());
                        minsum = min(minsum, sumvec(c, r-l));
                        //cout << "s2: " << sumvec(c, r-l) << "\n";
                }
                
                t--;
                cout << minsum << "\n";
        }
        

        return 0;
}

int sumvec(vector<int> v, int stop){
        int sum = 0;
        for(int i = 0;i < stop; i++){
                sum += v[i];
        }
        return sum;
}
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;
int main(){
int t;
cin>>t;
    while(t--){
        int i,j,k,r,l,n,m;
        cin>>l>>r;
        int a[2][30];
        for(i=0 ; i < 30; i++)
        {
            a[0][i]=0;
            a[1][i]=0;
        }
i=0;
int l1=l,r1=r;
        while(l){
            a[0][i]=l&1;
            l=l>>1;
            i++;
        }
i=0;
        while(r){
            a[1][i]=r&1;
            r=r>>1;
            i++;
        }
l=0;
        for(i=29;i>=0;i--){
            if(a[0][i]!=a[1][i]){
                j=pow(2,i);
                k=j-1;
                break;
            }
        }
if(k>l1)l=l1;
else l=j+1;

        cout<<j<<" "<<k<<" "<<l<<endl;
    }
}