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


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		long long ans = 0;
		for (int i = 0; i < n - 1; i++) {
			ans = accumulate(a.begin(), a.end(), 0LL);
			if (a[0] < a.back()) {
				reverse(a.begin(), a.end());
			}
			long long sum = 0;
			for (int i = 0; i < a.size()-1; i++) {
				a[i] = a[i] - a[i + 1];
				sum += a[i];
			}
			ans = max(ans, sum);
			a.pop_back();
		}
		cout << ans << "\n";
	}
}
Problem: 2063B - Subsequence Update
Language: Java 21

Previous submission (verdict: Wrong answer on test 8):
import java.util.*;



public class Main

{

	public static void main(String[] args) {

		int t;

		Scanner sc = new Scanner(System.in);

		t = sc.nextInt();

		while(t > 0){

		    int n = sc.nextInt();

		    int l = sc.nextInt();

		    int r = sc.nextInt();

		    l--;

		    r--;

		    List<Integer> arr1 = new ArrayList<>();

		    List<Integer> arr2 = new ArrayList<>();

		    List<Integer> arr3 = new ArrayList<>();

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

		        arr1.add(sc.nextInt());

		    }

		    for (int i = l; i <= r; i++){

		        arr2.add(sc.nextInt());

		    }

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

		        arr3.add(sc.nextInt());

		    }

		    Collections.sort(arr1);

		    Collections.sort(arr2);

		    Collections.sort(arr3);

		  //  System.out.println(arr1);

		  //  System.out.println(arr2);

		  //  System.out.println(arr3);

		    int sum1 = 0, sum2 = 0;

		    int j = 0;

		    for (int i = arr2.size() - 1; i >= 0; i--){

		        int num1 = arr2.get(i);

		        if (j < arr1.size()){

		            num1 = Math.min(num1, arr1.get(j));

		            j++;

		        }

		        sum1 += num1;

		    }

		    j = 0;

		    for (int i = arr2.size() - 1; i >= 0; i--){

		        int num1 = arr2.get(i);

		        if (j < arr3.size()){

		            num1 = Math.min(num1, arr3.get(j));

		            j++;

		        }

		        sum2 += num1;

		    }

		    int ans = Math.min(sum1, sum2);

		    System.out.println(ans);

		    t--;

		}

	}

}

Submission (verdict: Compilation error):
import java.util.*;



public class Main

{

	public static void main(String[] args) {

		int t;

		Scanner sc = new Scanner(System.in);

		t = sc.nextInt();

		while(t > 0){

		    int n = sc.nextInt();

		    int l = sc.nextInt();

		    int r = sc.nextInt();

		    l--;

		    r--;

		    List<Integer> arr1 = new ArrayList<>();

		    List<Integer> arr2 = new ArrayList<>();

		    List<Integer> arr3 = new ArrayList<>();

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

		        arr1.add(sc.nextInt());

		    }

		    for (int i = l; i <= r; i++){

		        arr2.add(sc.nextInt());

		    }

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

		        arr3.add(sc.nextInt());

		    }

		    Collections.sort(arr1);

		    Collections.sort(arr2);

		    Collections.sort(arr3);

		  //  System.out.println(arr1);

		  //  System.out.println(arr2);

		  //  System.out.println(arr3);

		    long sum1 = 0, sum2 = 0;

		    int j = 0;

		    for (int i = arr2.size() - 1; i >= 0; i--){

		        int num1 = arr2.get(i);

		        if (j < arr1.size()){

		            num1 = Math.min(num1, arr1.get(j));

		            j++;

		        }

		        sum1 += num1;

		    }

		    j = 0;

		    for (int i = arr2.size() - 1; i >= 0; i--){

		        int num1 = arr2.get(i);

		        if (j < arr3.size()){

		            num1 = Math.min(num1, arr3.get(j));

		            j++;

		        }

		        sum2 += num1;

		    }

		    int ans = Math.min(sum1, sum2);

		    System.out.println(ans);

		    t--;

		}

	}

}
Problem: 2063B - Subsequence Update
Language: Java 21


Submission (verdict: Wrong answer on test 8):
import java.util.*;



public class Main

{

	public static void main(String[] args) {

		int t;

		Scanner sc = new Scanner(System.in);

		t = sc.nextInt();

		while(t > 0){

		    int n = sc.nextInt();

		    int l = sc.nextInt();

		    int r = sc.nextInt();

		    l--;

		    r--;

		    List<Integer> arr1 = new ArrayList<>();

		    List<Integer> arr2 = new ArrayList<>();

		    List<Integer> arr3 = new ArrayList<>();

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

		        arr1.add(sc.nextInt());

		    }

		    for (int i = l; i <= r; i++){

		        arr2.add(sc.nextInt());

		    }

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

		        arr3.add(sc.nextInt());

		    }

		    Collections.sort(arr1);

		    Collections.sort(arr2);

		    Collections.sort(arr3);

		  //  System.out.println(arr1);

		  //  System.out.println(arr2);

		  //  System.out.println(arr3);

		    int sum1 = 0, sum2 = 0;

		    int j = 0;

		    for (int i = arr2.size() - 1; i >= 0; i--){

		        int num1 = arr2.get(i);

		        if (j < arr1.size()){

		            num1 = Math.min(num1, arr1.get(j));

		            j++;

		        }

		        sum1 += num1;

		    }

		    j = 0;

		    for (int i = arr2.size() - 1; i >= 0; i--){

		        int num1 = arr2.get(i);

		        if (j < arr3.size()){

		            num1 = Math.min(num1, arr3.get(j));

		            j++;

		        }

		        sum2 += num1;

		    }

		    int ans = Math.min(sum1, sum2);

		    System.out.println(ans);

		    t--;

		}

	}

}
Problem: 2063B - Subsequence Update
Language: Java 21

Previous submission (verdict: Compilation error):
import java.util.*;



public class Main

{

	public static void main(String[] args) {

		int t;

		Scanner sc = new Scanner(System.in);

		t = sc.nextInt();

		while(t > 0){

		    int n = sc.nextInt();

		    int l = sc.nextInt();

		    int r = sc.nextInt();

		    l--;

		    r--;

		    List<Integer> arr1 = new ArrayList<>();

		    List<Integer> arr2 = new ArrayList<>();

		    List<Integer> arr3 = new ArrayList<>();

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

		        arr1.add(sc.nextInt());

		    }

		    for (int i = l; i <= r; i++){

		        arr2.add(sc.nextInt());

		    }

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

		        arr3.add(sc.nextInt());

		    }

		    Collections.sort(arr1);

		    Collections.sort(arr2);

		    Collections.sort(arr3);

		  //  System.out.println(arr1);

		  //  System.out.println(arr2);

		  //  System.out.println(arr3);

		    long sum1 = 0, sum2 = 0;

		    int j = 0;

		    for (int i = arr2.size() - 1; i >= 0; i--){

		        int num1 = arr2.get(i);

		        if (j < arr1.size()){

		            num1 = Math.min(num1, arr1.get(j));

		            j++;

		        }

		        sum1 += num1;

		    }

		    j = 0;

		    for (int i = arr2.size() - 1; i >= 0; i--){

		        int num1 = arr2.get(i);

		        if (j < arr3.size()){

		            num1 = Math.min(num1, arr3.get(j));

		            j++;

		        }

		        sum2 += num1;

		    }

		    int ans = Math.min(sum1, sum2);

		    System.out.println(ans);

		    t--;

		}

	}

}

Submission (verdict: Accepted):
import java.util.*;

public class Main
{
	public static void main(String[] args) {
		int t;
		Scanner sc = new Scanner(System.in);
		t = sc.nextInt();
		while(t > 0){
		    int n = sc.nextInt();
		    int l = sc.nextInt();
		    int r = sc.nextInt();
		    l--;
		    r--;
		    List<Integer> arr1 = new ArrayList<>();
		    List<Integer> arr2 = new ArrayList<>();
		    List<Integer> arr3 = new ArrayList<>();
		    for (int i = 0; i < l; i++){
		        arr1.add(sc.nextInt());
		    }
		    for (int i = l; i <= r; i++){
		        arr2.add(sc.nextInt());
		    }
		    for (int i = r + 1; i < n; i++){
		        arr3.add(sc.nextInt());
		    }
		    Collections.sort(arr1);
		    Collections.sort(arr2);
		    Collections.sort(arr3);
		  //  System.out.println(arr1);
		  //  System.out.println(arr2);
		  //  System.out.println(arr3);
		    long sum1 = 0, sum2 = 0;
		    int j = 0;
		    for (int i = arr2.size() - 1; i >= 0; i--){
		        int num1 = arr2.get(i);
		        if (j < arr1.size()){
		            num1 = Math.min(num1, arr1.get(j));
		            j++;
		        }
		        sum1 += num1;
		    }
		    j = 0;
		    for (int i = arr2.size() - 1; i >= 0; i--){
		        int num1 = arr2.get(i);
		        if (j < arr3.size()){
		            num1 = Math.min(num1, arr3.get(j));
		            j++;
		        }
		        sum2 += num1;
		    }
		    long ans = Math.min(sum1, sum2);
		    System.out.println(ans);
		    t--;
		}
	}
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long t; cin>>t;
    string num;
    while(t--){
      cin>>num;
      for(int k=0;k<1000;k++){
      for(int i=num.length()-1;i>0;i--){
        if(num[i]-1>num[i-1]){
          num[i]=num[i]-1;
          swap(num[i],num[i-1]);
        }
      }
      }
      cout<<num<<"\n";
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long t; cin>>t;
    string num; bool pom;
    while(t--){
      cin>>num;
      pom=1;
      while(pom){
        pom=0;
      for(int i=num.length()-1;i>0;i--){
        if(num[i]-1>num[i-1]){
          num[i]=num[i]-1;
          swap(num[i],num[i-1]);
          pom=1;
        }
      }
      }
      cout<<num<<"\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long t; cin>>t;
    string num;
    while(t--){
      cin>>num;
      for(int k=0;k<10;k++){
      for(int i=num.length()-1;i>0;i--){
        if(num[i]-1>num[i-1]){
          num[i]=num[i]-1;
          swap(num[i],num[i-1]);
        }
      }
      }
      cout<<num<<"\n";
    }
    return 0;
}

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

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long t; cin>>t;
    string num;
    while(t--){
      cin>>num;
      for(int k=0;k<1000;k++){
      for(int i=num.length()-1;i>0;i--){
        if(num[i]-1>num[i-1]){
          num[i]=num[i]-1;
          swap(num[i],num[i-1]);
        }
      }
      }
      cout<<num<<"\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long t; cin>>t;
    string num; bool pom;
    while(t--){
      cin>>num;
      pom=1;
      while(pom){
        pom=0;
      for(int i=num.length()-1;i>0;i--){
        if(num[i]-1>num[i-1]){
          num[i]=num[i]-1;
          swap(num[i],num[i-1]);
          pom=1;
        }
      }
      }
      cout<<num<<"\n";
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
void solve() {
    string s; cin>>s;
    for(int i=0;i<s.size();i++){
        int best=s[i]-'0',pos=i;
        for(int j=i;j<min(i+10,(int)s.size());j++){
            if(s[j]-'0'-j+i>best){
                best=s[j]-'0'-j+i;
                pos=j;
            }
        }
        while(pos>i){
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i]=char(best+'0');
    }
    cout<<s;
}
int main() {
    int TESTS; cin>>TESTS;
    while(TESTS--){
        solve();
        cout<<'\n';
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long t; cin>>t;
    string num;
    while(t--){
      cin>>num;
      for(int k=0;k<10;k++){
      for(int i=num.length()-1;i>0;i--){
        if(num[i]-1>num[i-1]){
          num[i]=num[i]-1;
          swap(num[i],num[i-1]);
        }
      }
      }
      cout<<num<<"\n";
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<pair<int, int>> res;
  vector<int> b(n);
  iota(b.begin(), b.end(), 1);
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= i; ++j) {
      if (b[j] == a[i]) {
        for (int k = j - 1; k >= 0; --k) {
          res.emplace_back(b[k + 1], b[k]);
          swap(b[k], b[k + 1]);
        }
        for (int k = 0; k < i; ++k) {
          res.emplace_back(b[k], b[k + 1]);
          swap(b[k], b[k + 1]);
        }
        break;
      }
    }
  }
  cout << res.size() << '\n';
  for (auto [x, y] : res) {
    cout << x << ' ' << y << '\n';
  }
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<pair<int, int>> res;
  vector<int> b(n);
  iota(b.begin(), b.end(), 1);
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= i; ++j) {
      if (b[j] == a[i]) {
        for (int k = j - 1; k >= 0; --k) {
          res.emplace_back(b[k + 1], b[k]);
          swap(b[k], b[k + 1]);
        }
        for (int k = 0; k < i; ++k) {
          res.emplace_back(b[k + 1], b[k]);
          swap(b[k], b[k + 1]);
        }
        break;
      }
    }
  }
  cout << res.size() << '\n';
  for (auto [x, y] : res) {
    cout << x << ' ' << y << '\n';
  }
  return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<pair<int, int>> res;
  vector<int> b(n);
  iota(b.begin(), b.end(), 1);
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= i; ++j) {
      if (b[j] == a[i]) {
        for (int k = j - 1; k >= 0; --k) {
          res.emplace_back(b[k], b[k + 1]);
          swap(b[k], b[k + 1]);
        }
        for (int k = 0; k < i; ++k) {
          res.emplace_back(b[k], b[k + 1]);
          swap(b[k], b[k + 1]);
        }
        break;
      }
    }
  }
  cout << res.size() << '\n';
  for (auto [x, y] : res) {
    cout << x << ' ' << y << '\n';
  }
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<pair<int, int>> res;
  vector<int> b(n);
  iota(b.begin(), b.end(), 1);
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= i; ++j) {
      if (b[j] == a[i]) {
        for (int k = j - 1; k >= 0; --k) {
          res.emplace_back(b[k + 1], b[k]);
          swap(b[k], b[k + 1]);
        }
        for (int k = 0; k < i; ++k) {
          res.emplace_back(b[k], b[k + 1]);
          swap(b[k], b[k + 1]);
        }
        break;
      }
    }
  }
  cout << res.size() << '\n';
  for (auto [x, y] : res) {
    cout << x << ' ' << y << '\n';
  }
  return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<pair<int, int>> res;
  vector<int> b(n);
  iota(b.begin(), b.end(), 1);
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= i; ++j) {
      if (b[j] == a[i]) {
        for (int k = j - 1; k >= 0; --k) {
          res.emplace_back(b[k], b[k + 1]);
          swap(b[k], b[k + 1]);
        }
        for (int k = 0; k < i; ++k) {
          res.emplace_back(b[k], b[k + 1]);
          swap(b[k], b[k + 1]);
        }
        break;
      }
    }
  }
  cout << res.size() << '\n';
  for (auto [x, y] : res) {
    cout << x << ' ' << y << '\n';
  }
  return 0;
}
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 pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define int long long
#define pi pair<int,int>


void solve(){
	int l,r;	cin >> l >> r;
	int ll = l, rr = r;
	int bit = log2(r);
	int a = 0, b = 0;
	while(bit >= 0){
		int pw = 1 << bit;

		if( (l&pw) == 0 and (r&pw) ){
			a += pw;
			for( int i = bit-1; i >= 0; --i){
				b += 1 << i;
			}
			break;
		}
		else{
			a += pw;
			b += pw;
		}
		l /= 2;	r /= 2;
		bit -= 1;
	}
	int c;
	for( int i = ll; i <= rr; ++i)	{
		if( i != a and i != b){
			c = i;
			break;
		}
	}
		
	cout << a << " " << b << " " << c ;
 	   
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int test = 1;   
    cin >> test;
    while( test--){
        solve();
	    cout << "\n";
    }

    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;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define int long long
#define pi pair<int,int>


void solve(){
	int l,r;	cin >> l >> r;
	int bit = log2(r);
	int a = 0, b = 0;
	while(bit >= 0){
		int pw = 1 << bit;

		if( (l&pw) == 0 and (r&pw) ){
			a += pw;
			for( int i = bit-1; i >= 0; --i){
				b += 1 << i;
			}
			break;
		}
		else if( (l&pw)  and (r&pw) ){
			a += pw;
			b += pw;
		}

		bit -= 1;
	}
	int c;
	for( int i = l; i <= r; ++i)	{
		if( i != a and i != b){
			c = i;
			break;
		}
	}
		
	cout << a << " " << b << " " << c ;
 	   
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int test = 1;   
    cin >> test;
    while( test--){
        solve();
	    cout << "\n";
    }

    return 0;
}


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




void Solve()
{

    int a, b;
    cin >> a >> b;
if(a > b) swap(a,b);
bitset<52> bitsA(a);
bitset<52> bitsB(b);
string sA;
string sB;
int index = -1;
for(int i = 51 ; i >= 0 ; i--){
    if(bitsA[i] != bitsB[i]){
        index = i;
        break;
    }
}
string ans;

for(int i = index ; i >= 0 ; i--){
    sA += bitsA[i] + '0';
    sB += bitsB[i] + '0';
    ans += !(bitsA[i] & bitsB[i]) + '0';
}


for(int i = index ; i >= 0 ; i--){
    if(sA != sB){
        string cur = ans;
        cur[i] = '0';
        if(cur < sB && cur > sA){
            ans = cur;
        }
    }
}


bitset<52> bitsC(a);

for(int i = 0 ; i <= index ; i++){
    bitsC[i] = ans[index - i] -'0';
}
cout<<a<<" "<<bitsC.to_ullong()<< " " <<b<<endl;


}


int32_t main(){

   int t;
   cin >> t;
   for(int i = 0 ; i <t ; i++){
    Solve();
   }
}
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;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define int long long
#define pi pair<int,int>


void solve(){
	int l,r;	cin >> l >> r;
	int ll = l, rr = r;
	int bit = log2(r);
	int a = 0, b = 0;
	while(bit >= 0){
		int pw = 1 << bit;

		if( (l&pw) == 0 and (r&pw) ){
			a += pw;
			for( int i = bit-1; i >= 0; --i){
				b += 1 << i;
			}
			break;
		}
		else{
			a += pw;
			b += pw;
		}
		l /= 2;	r /= 2;
		bit -= 1;
	}
	int c;
	for( int i = ll; i <= rr; ++i)	{
		if( i != a and i != b){
			c = i;
			break;
		}
	}
		
	cout << a << " " << b << " " << c ;
 	   
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int test = 1;   
    cin >> test;
    while( test--){
        solve();
	    cout << "\n";
    }

    return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define int long long
#define pi pair<int,int>


void solve(){
	int l,r;	cin >> l >> r;
	int bit = log2(r);
	int a = 0, b = 0;
	while(bit >= 0){
		int pw = 1 << bit;

		if( (l&pw) == 0 and (r&pw) ){
			a += pw;
			for( int i = bit-1; i >= 0; --i){
				b += 1 << i;
			}
			break;
		}
		else if( (l&pw)  and (r&pw) ){
			a += pw;
			b += pw;
		}

		bit -= 1;
	}
	int c;
	for( int i = l; i <= r; ++i)	{
		if( i != a and i != b){
			c = i;
			break;
		}
	}
		
	cout << a << " " << b << " " << c ;
 	   
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int test = 1;   
    cin >> test;
    while( test--){
        solve();
	    cout << "\n";
    }

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define int long long
#define pi pair<int,int>

int connected_comp(vector<set<int>> graph, int a, int b){
	int n = graph.size()-1;
	vector<int> visited(n+1);
	// lambda expression for dfs call	
	function< void(int,int)> dfs = [&](int curr,int par) {
		visited[curr] = 1;
		for( int i : graph[curr]){
			if( i != par)
				dfs(i , curr);
		}
		
	};
	
	int ans = 0;
	for( int i = 1; i <= n; ++i){
		if( !visited[i] and graph[i].size() > 0){
			ans += 1;
			dfs(i,-1);
		}
		else if( !visited[i] and graph[i].size() == 0){
			if( i != a and i != b)	{
				ans += 1;
			}
		}
	}
	return ans;
}

int remove( vector< set<int>>& graph){
	int n = graph.size()-1;
	
	vector<pi> mp(n);
	for( int i = 1; i <= n; ++i)
		mp[i-1] = {graph[i].size() , i};

	sort( rall(mp));
	int a = mp[0].second;
	
	// remove node 'a' and all of its edges

	graph[a].clear();
	for( int k = 1; k <= n; ++k){
	    if( graph[k].find(a) != graph[k].end())
			graph[k].erase( graph[k].find(a));
	}
	return a;	
	
}
void print(vector<set<int>> graph){
	int n = graph.size()-1;
	for( int i = 1; i <= n; ++i){
		cout << i << " : ";
		for( int j : graph[i])
			cout << j << " ";
		cout << endl;
	}
}
void solve(){
	int n;	cin >> n;
	vector< set<int>> graph(n+1);
	vector<int> freq(n+1);
	for( int i = 0; i < n-1; ++i){
		int a,b;	cin >> a >> b;
		graph[a].insert(b);
		graph[b].insert(a);		
		freq[a] += 1;
		freq[b] += 1;
	}	

	int a = remove( graph);
	int b = remove(graph);

	int ans = connected_comp(graph,a,b);
	
	if( n == 2)	cout << 0;
	else
		cout << ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    int test = 1;   
    cin >> test;
    while( test--){
        solve();
	    cout << "\n";
    }

    return 0;
}