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;

int main(){
    int t;
    cin>>t;
    while(t--){
        int l,r;
        cin>>l>>r;
        string s=bitset<32>(l).to_string();
        string p=bitset<32>(r).to_string();
        string a="";
        string b="";
        string c="";
        int pick=0;
        for(int i=0;i<32;i++){
            if(s[i]==p[i]){
                a+=s[i];
                b+=s[i];
                c+=s[i];
            }
            else{
                if(s[i]=='1'){
                    a+='0';
                    b+='1';
                }
                else{
                    a+='1';
                    b+='0';
                }
                pick=i;
                break;
                
            }
            
        }
        for(int i=pick+1;i<32;i++){
            if(a[i-1]=='1'){
                a+='0';
                b+='1';
                c+='0';
            }
            else{
                a+='1';
                b+='0';
                c+='1';
            }
        }
        bitset<32>fa(a);
        bitset<32>fb(b);
        bitset<32>fc(c);
        unsigned long aa=fa.to_ulong();
        unsigned long ab=fb.to_ulong();
        unsigned long ac=fc.to_ulong();
        // int xori=aa^ab+ab^ac+aa^ac;
        // cout<<xori<<endl;
        cout<<aa<<" "<<ab<<" "<<ac<<endl;
    }
}

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;

        long long a = r, b = r - 1, c = r - 2;

        // Precomputed XOR results for selected numbers
        long long max_sum = (a ^ b) + (b ^ c) + (a ^ c);
        
        // Explore combination including `l` for edge cases
        long long alt_a = r, alt_b = r - 1, alt_c = l;
        long long sum_alt = (alt_a ^ alt_b) + (alt_b ^ alt_c) + (alt_a ^ alt_c);

        if (sum_alt > max_sum) {
            a = alt_a; b = alt_b; c = alt_c;
            max_sum = sum_alt;
        }

        // Output the best combination found
        cout << a << " " << b << " " << c << endl;
    }
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;



#ifndef ONLINE_JUDGE

#include <D:/deb.hpp>

#else

#define p(...);

#define Case(x);

#define bl ;

#endif

#define int long long



#define pb push_back

#define ff first

#define ss second

#define sz(x) (int)x.size()

#define all(x) begin(x), end(x)

#define rall(x) rbegin(x), rend(x)



#ifdef ONLINE_JUDGE

#define STATER

#else

#define STATER freopen("E.txt", "w", stderr);

#endif



#define TCS(x) ios::sync_with_stdio(0);cin.tie(0); \

int t = 0; if (!x)cin >> t; else t = x; for (int i = 1; i <= t; i++){Case(i); solve(); bl}

template<class...T> void _i_(T &...s) {

	(void)initializer_list<int> {(cin >> s, 0)...};

}

#define in(...) int __VA_ARGS__;_i_(__VA_ARGS__)

#define chr(...) char __VA_ARGS__; _i_(__VA_ARGS__)

#define str(...) string __VA_ARGS__; _i_(__VA_ARGS__)

#define vec(T,v,n) vector<T> v(n); for (auto &x : v) cin >> x

#define vp(S,T,v,n) vector<pair<S,T>>v(n); for(auto & x : v) cin >> x.first >> x.second

#define vvec(T,v,n,m) vector<vector<T>>v(n, vector<T>(m)); for (auto &i : v)for (auto &j : i)cin >> j



auto solve() {

	in(n, x, y);

	map<int, vector<int>>mp;

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

		int left = (i - 1 + n) % n, right = (i + 1) % n;

		mp[i] = {left, right};

		if (x == i + 1)mp[i].pb(y - 1);

		if (y == i + 1)mp[i].pb(x - 1);

	}

	vector<int> ans(n, 0);

	for (auto &i : mp) {

		vector<bool> seen(n + 1, false);

		for (auto &j : i.ss)

			seen[ans[j]] = 1;

		int mex = 0;

		while (seen[mex])mex++;

		ans[i.ff] = mex;

	}

	for (auto &i : ans)

		cout << i << ' ';

	cout << endl;

}

signed main() {

	STATER;

	TCS(0);

}





	}

	for (auto &i : ans)

		cout << i << ' ';

	cout << endl;

}

signed main() {

	STATER;

	TCS(0);

}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  unordered_map<int, int> freq;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    freq[v[i]]++;
  }

  int len = freq.size();

  vector<int> counts;
  counts.reserve(len);

  for (auto &p : freq) {
    counts.push_back(p.second);
  }
  sort(counts.begin(), counts.end());

  int remove = 0;
  for (auto c : counts) {
    if (k >= c) {
      k -= c;
      remove++;
    } else {
      cout << len - remove << '\n';
      return;
    }
  }

  cout << "1\n";
}

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

  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

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

  vector<int> freq;
  freq.reserve(n);

  int currCount = 1;
  for (int i = 1; i < n; i++) {
    if (v[i] == v[i - 1]) {
      currCount++;
    } else {
      freq.push_back(currCount);
      currCount = 1;
    }
  }
  freq.push_back(currCount);

  int len = freq.size();

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

  int remove = 0;
  for (auto c : freq) {
    if (k >= c) {
      k -= c;
      remove++;
    } else {
      cout << (len - remove) << "\n";
      return;
    }
  }

  cout << "1\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  unordered_map<int, int> freq;
  for (auto x : v) {
    freq[x]++;
  }

  int len = freq.size();

  vector<int> counts(len);

  for (auto &p : freq) {
    counts.push_back(p.second);
  }
  sort(counts.begin(), counts.end());

  int remove = 0;
  for (auto c : counts) {
    if (k >= c) {
      k -= c;
      remove++;
    } else {
      cout << len - remove << '\n';
      return;
    }
  }

  cout << "1\n";
}

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

  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  unordered_map<int, int> freq;
  for (auto x : v) {
    freq[x]++;
  }

  int len = freq.size();

  vector<int> counts;
  counts.reserve(len);

  for (auto &p : freq) {
    counts.push_back(p.second);
  }
  sort(counts.begin(), counts.end());

  int remove = 0;
  for (auto c : counts) {
    if (k >= c) {
      k -= c;
      remove++;
    } else {
      cout << len - remove << '\n';
      return;
    }
  }

  cout << "1\n";
}

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

  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  unordered_map<int, int> freq;
  for (auto x : v) {
    freq[x]++;
  }

  int len = freq.size();

  vector<int> counts(len);

  for (auto &p : freq) {
    counts.push_back(p.second);
  }
  sort(counts.begin(), counts.end());

  int remove = 0;
  for (auto c : counts) {
    if (k >= c) {
      k -= c;
      remove++;
    } else {
      cout << len - remove << '\n';
      return;
    }
  }

  cout << "1\n";
}

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

  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  unordered_map<int, int> freq;
  for (auto x : v) {
    freq[x]++;
  }

  int len = freq.size();

  vector<int> counts;
  counts.reserve(len);

  for (auto &p : freq) {
    counts.push_back(p.second);
  }
  sort(counts.begin(), counts.end());

  int remove = 0;
  for (auto c : counts) {
    if (k >= c) {
      k -= c;
      remove++;
    } else {
      cout << len - remove << '\n';
      return;
    }
  }

  cout << "1\n";
}

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

  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  unordered_map<int, int> freq;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    freq[v[i]]++;
  }

  int len = freq.size();

  vector<int> counts;
  counts.reserve(len);

  for (auto &p : freq) {
    counts.push_back(p.second);
  }
  sort(counts.begin(), counts.end());

  int remove = 0;
  for (auto c : counts) {
    if (k >= c) {
      k -= c;
      remove++;
    } else {
      cout << len - remove << '\n';
      return;
    }
  }

  cout << "1\n";
}

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

  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


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

void solve() {
  int n;
  cin >> n;

  vector<vector<int>> graph(n + 1);
  vector<int> degree(n + 1, 0);

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);

    degree[u]++;
    degree[v]++;
  }

  vector<pair<int, int>> candidates;
  for (int i = 1; i <= n; i++)
    candidates.push_back({degree[i], i});

  sort(candidates.rbegin(), candidates.rend());

  int k = min(n, 200);
  vector<pair<int, int>> topcans(candidates.begin(), candidates.begin() + k);

  vector<unordered_set<int>> neighbors(k);
  for (int i = 0; i < k; i++) {
    int v = topcans[i].second;
    for (int neighbor : graph[v])
      neighbors[i].insert(neighbor);
  }

  ll best = 0;
  for (int i = 0; i < k; i++) {
    for (int j = i + 1; j < k; j++) {
      int u = topcans[i].second;
      int v = topcans[j].second;

      bool adj = (neighbors[i].find(v) != neighbors[i].end());
      ll current = degree[u] + degree[v] - 1 - (adj ? 1 : 0);

      best = max(best, current);
    }
  }

  cout << best << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

void solve() {
  int n;
  cin >> n;

  vector<vector<int>> graph(n + 1);
  vector<int> degree(n + 1, 0);

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);

    degree[u]++;
    degree[v]++;
  }

  vector<pair<int, int>> candidates;
  for (int i = 1; i <= n; i++)
    candidates.push_back({degree[i], i});

  sort(candidates.rbegin(), candidates.rend());

  int k = min(n, 2000);
  vector<pair<int, int>> topcans(candidates.begin(), candidates.begin() + k);

  vector<unordered_set<int>> neighbors(k);
  for (int i = 0; i < k; i++) {
    int v = topcans[i].second;
    for (int neighbor : graph[v])
      neighbors[i].insert(neighbor);
  }

  ll best = 0;
  for (int i = 0; i < k; i++) {
    for (int j = i + 1; j < k; j++) {
      int u = topcans[i].second;
      int v = topcans[j].second;

      bool adj = (neighbors[i].find(v) != neighbors[i].end());
      ll current = degree[u] + degree[v] - 1 - (adj ? 1 : 0);

      best = max(best, current);
    }
  }

  cout << best << '\n';
}

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

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

void solve() {
  int n;
  cin >> n;

  vector<vector<int>> graph(n + 1);
  vector<int> degree(n + 1, 0);

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);

    degree[u]++;
    degree[v]++;
  }

  vector<pair<int, int>> candidates;
  for (int i = 1; i <= n; i++)
    candidates.push_back({degree[i], i});

  sort(candidates.rbegin(), candidates.rend());

  int k = min(n, 10000);
  vector<pair<int, int>> topcans(candidates.begin(), candidates.begin() + k);

  vector<unordered_set<int>> neighbors(k);
  for (int i = 0; i < k; i++) {
    int v = topcans[i].second;
    for (int neighbor : graph[v])
      neighbors[i].insert(neighbor);
  }

  ll best = 0;
  for (int i = 0; i < k; i++) {
    for (int j = i + 1; j < k; j++) {
      int u = topcans[i].second;
      int v = topcans[j].second;

      bool adj = (neighbors[i].find(v) != neighbors[i].end());
      ll current = degree[u] + degree[v] - 1 - (adj ? 1 : 0);

      best = max(best, current);
    }
  }

  cout << best << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

void solve() {
  int n;
  cin >> n;

  vector<vector<int>> graph(n + 1);
  vector<int> degree(n + 1, 0);

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);

    degree[u]++;
    degree[v]++;
  }

  vector<pair<int, int>> candidates;
  for (int i = 1; i <= n; i++)
    candidates.push_back({degree[i], i});

  sort(candidates.rbegin(), candidates.rend());

  int k = min(n, 10000);
  vector<pair<int, int>> topcans(candidates.begin(), candidates.begin() + k);

  vector<unordered_set<int>> neighbors(k);
  for (int i = 0; i < k; i++) {
    int v = topcans[i].second;
    for (int neighbor : graph[v])
      neighbors[i].insert(neighbor);
  }

  ll best = 0;
  for (int i = 0; i < k; i++) {
    for (int j = i + 1; j < k; j++) {
      int u = topcans[i].second;
      int v = topcans[j].second;

      bool adj = (neighbors[i].find(v) != neighbors[i].end());
      ll current = degree[u] + degree[v] - 1 - (adj ? 1 : 0);

      best = max(best, current);
    }
  }

  cout << best << '\n';
}

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

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

void solve() {
  int n;
  cin >> n;
  vector<vector<int>> graph(n + 1);
  vector<int> degree(n + 1, 0);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
    degree[u]++;
    degree[v]++;
  }
  for (int u = 1; u <= n; u++)
    sort(graph[u].begin(), graph[u].end());
  vector<pair<int, int>> L;
  L.reserve(n);
  for (int u = 1; u <= n; u++)
    L.push_back({degree[u], u});
  sort(L.rbegin(), L.rend());
  ll best_nonadj = -1;
  for (int u = 1; u <= n; u++) {
    ll candidate = -1;
    for (auto &p : L) {
      int v = p.second;
      if (v == u) continue;
      if (binary_search(graph[u].begin(), graph[u].end(), v)) continue;
      candidate = (ll)degree[u] + degree[v] - 1;
      break;
    }
    best_nonadj = max(best_nonadj, candidate);
  }
  ll best_adj = -1;
  for (int u = 1; u <= n; u++) {
    for (int v : graph[u])
      if (v > u)
        best_adj = max(best_adj, (ll)degree[u] + degree[v] - 2);
  }
  ll ans = max(best_nonadj, best_adj);
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

void solve() {
  int n;
  cin >> n;

  vector<vector<int>> graph(n + 1);
  vector<int> degree(n + 1, 0);

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);

    degree[u]++;
    degree[v]++;
  }

  vector<pair<int, int>> candidates;
  for (int i = 1; i <= n; i++)
    candidates.push_back({degree[i], i});

  sort(candidates.rbegin(), candidates.rend());

  int k = min(n, 200);
  vector<pair<int, int>> topcans(candidates.begin(), candidates.begin() + k);

  vector<unordered_set<int>> neighbors(k);
  for (int i = 0; i < k; i++) {
    int v = topcans[i].second;
    for (int neighbor : graph[v])
      neighbors[i].insert(neighbor);
  }

  ll best = 0;
  for (int i = 0; i < k; i++) {
    for (int j = i + 1; j < k; j++) {
      int u = topcans[i].second;
      int v = topcans[j].second;

      bool adj = (neighbors[i].find(v) != neighbors[i].end());
      ll current = degree[u] + degree[v] - 1 - (adj ? 1 : 0);

      best = max(best, current);
    }
  }

  cout << best << '\n';
}

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

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

void solve() {
  int n;
  cin >> n;

  vector<vector<int>> graph(n + 1);
  vector<int> degree(n + 1, 0);

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);

    degree[u]++;
    degree[v]++;
  }

  vector<pair<int, int>> candidates;
  for (int i = 1; i <= n; i++)
    candidates.push_back({degree[i], i});

  sort(candidates.rbegin(), candidates.rend());

  int k = min(n, 2000);
  vector<pair<int, int>> topcans(candidates.begin(), candidates.begin() + k);

  vector<unordered_set<int>> neighbors(k);
  for (int i = 0; i < k; i++) {
    int v = topcans[i].second;
    for (int neighbor : graph[v])
      neighbors[i].insert(neighbor);
  }

  ll best = 0;
  for (int i = 0; i < k; i++) {
    for (int j = i + 1; j < k; j++) {
      int u = topcans[i].second;
      int v = topcans[j].second;

      bool adj = (neighbors[i].find(v) != neighbors[i].end());
      ll current = degree[u] + degree[v] - 1 - (adj ? 1 : 0);

      best = max(best, current);
    }
  }

  cout << best << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  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;

int reverseBits(int n)
{
    int rev = 0;
    while (n > 0) {
        rev <<= 1;
 
        if (n & 1 == 1)
            rev ^= 1;
        n >>= 1;
    }
 
    return rev;
}

int main(){
    int t;
    cin>>t;
    while(t--){
		int a,b;
		cin>>a>>b;
        int c=a+reverseBits(a^b);
        cout<<a<<" "<<b<<" "<<c<<endl;
        
    }
    return 0;
}

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

int reverseBits(int n)
{
    int numberOfBits = sizeof(int) * 8 - __builtin_clz(n); 
    int mask = (1 << numberOfBits) - 1;
    return n ^ mask;
}

int main(){
    int t;
    cin>>t;
    while(t--){
		int a,b;
		cin>>a>>b;
        int c=a+reverseBits(a^b);
        cout<<a<<" "<<b<<" "<<c<<endl;
        
    }
    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;

int reverseBits(int n)
{
    int rev = 0;
    while (n > 0) {
        rev <<= 1;
 
        if (n & 1 == 1)
            rev ^= 1;
        n >>= 1;
    }
 
    return rev;
}

int main(){
    int t;
    cin>>t;
    while(t--){
		int a,b;
		cin>>a>>b;
        int c=a+reverseBits(a^b);
        cout<<a<<" "<<b<<" "<<c<<endl;
        
    }
    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;

int reverseBits(int n)
{
    int numberOfBits = sizeof(int) * 8 - __builtin_clz(n); 
    int mask = (1 << numberOfBits) - 1;
    return n ^ mask;
}

int main(){
    int t;
    cin>>t;
    while(t--){
		int a,b;
		cin>>a>>b;
        int c=a+reverseBits(a^b);
        cout<<a<<" "<<b<<" "<<c<<endl;
        
    }
    return 0;
}

 

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

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll l,r;
        cin>>l>>r;
        ll a,b,c;
        ll ans=0;
        for(int i=30;i>=0;i--){
            ll b1=0;
            ll b2=0;
            if(l & (1ll << i)) 
                b1=1;
            if(r & (1ll << i)) 
                b2=1;
            if(b1==b2){
                ans+=b1*(1ll <<i);
            }
            else{
                a=ans+(1ll << i);
                b=a-1;
                break;
            }
        }
        for(ll i=l;i<=r;i++){
            if(i!=a && i!=b){
                c=i;
                break;
            }
        }
        cout << a << " " << b << " " << c << endl;
    }
    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;
const char nl = '\n';
const char sp = ' ';
const int inf = 0x3f3f3f3f;
const string OUT[2]{ "NO", "YES" };
const string out[2]{ "No", "Yes" };
#define all(a) a.begin(), a.end()
#define dbg(a) cerr << (#a) << " = " << a << nl
#define OK() cerr << "OK until line " << __LINE__ << nl
using ll = long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ifstream fin(".in");
ofstream fout(".out");

auto start_time = chrono::high_resolution_clock::now();

double amcbn() {
    auto end_time = chrono::high_resolution_clock::now();
    return chrono::duration<double>(end_time - start_time).count();
}

template<typename T>
int rand(T a, T b) { return uniform_int_distribution<T>(a, b)(rng); }

template<typename T1, typename T2>
bool ckmax(T1& a, T2 b) { return a < b ? a = b, true : false; }

template<typename T1, typename T2>
bool ckmin(T1& a, T2 b) { return a > b ? a = b, true : false; }


// Idee: a = b = x, c = y
void testcase() {
    long long l, r;
    cin >> l >> r;
    long long x = l, y = r;
    for (int i = 31; i >= 0; --i) {
        if (!((x >> i) & 1) && ((y >> i) & 1)) {
            x = (((x >> i) | 1) << i) - 1;
            y = (y >> i) << i;
            break;
        }
    }
    cout << x << " " << x << " " << y << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; ++t) {
#ifdef _DEBUG
        cerr << "=== Subtask " << t << " ===" << nl;
#endif
        testcase();
#ifdef _DEBUG
        cerr << nl;
#endif
    }
}