ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using ld = long double;
const int N = 1e6+ 10;
int mod = 1e9 + 7;
ll n,m;
ll a[N], b[N];
// int tree[N];
string s;
char c1,c2,c3;
priority_queue<ll, vector<ll>, greater<ll>> qmin;
priority_queue<ll> qmax;
ll max(ll aa, ll bb){return aa > bb?aa:bb;}
ll min(ll aa, ll bb){return aa < bb?aa:bb;}
ll qm(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = ret * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ret;
}
// int find(int x){
//     return fa[x] == x?x:fa[x] = find(fa[x]);
// }

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    vector<pi> st;
    for(int i = n; i >= 1; i--) {
        for(int j = i - 1; j >= 1; j--) {
            st.push_back({i, j});
        }
    }
    map<int, int> mp;
    for(int i = 1; i <= n; i++) b[i] = n + 1 - i, mp[n + 1 - i] = i;
    for(int i = 1; i <= n; i++) {
        int index = mp[a[i]];
        for(int j = index - 1; j >= i; j--) {
            st.push_back({a[i], b[j]});
            swap(b[index], b[j]);
        }
    }
    cout << st.size() << '\n';
    for(auto i: st) cout << i.first << ' ' << i.second << '\n';
}
int main()
{
  // 请在此输入您的代码
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
//     cin >> _;
    while(_--) solve();
}

Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using ld = long double;
const int N = 1e6+ 10;
int mod = 1e9 + 7;
ll n,m;
ll a[N], b[N];
// int tree[N];
string s;
char c1,c2,c3;
priority_queue<ll, vector<ll>, greater<ll>> qmin;
priority_queue<ll> qmax;
ll max(ll aa, ll bb){return aa > bb?aa:bb;}
ll min(ll aa, ll bb){return aa < bb?aa:bb;}
ll qm(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = ret * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ret;
}
// int find(int x){
//     return fa[x] == x?x:fa[x] = find(fa[x]);
// }

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    vector<pi> st;
    for(int i = n; i >= 1; i--) {
        for(int j = i - 1; j >= 1; j--) {
            st.push_back({i, j});
        }
    }
    map<int, int> mp;
    for(int i = 1; i <= n; i++) b[i] = n + 1 - i, mp[n + 1 - i] = i;
    for(int i = 1; i <= n; i++) {
        int index = mp[a[i]];
        for(int j = index - 1; j >= i; j--) {
            st.push_back({b[j + 1], b[j]});
            swap(b[j + 1], b[j]);
        }
    }
    cout << st.size() << '\n';
    for(auto i: st) cout << i.first << ' ' << i.second << '\n';
}
int main()
{
  // 请在此输入您的代码
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
//     cin >> _;
    while(_--) solve();
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using ld = long double;
const int N = 1e6+ 10;
int mod = 1e9 + 7;
ll n,m;
ll a[N], b[N];
// int tree[N];
string s;
char c1,c2,c3;
priority_queue<ll, vector<ll>, greater<ll>> qmin;
priority_queue<ll> qmax;
ll max(ll aa, ll bb){return aa > bb?aa:bb;}
ll min(ll aa, ll bb){return aa < bb?aa:bb;}
ll qm(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = ret * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ret;
}
// int find(int x){
//     return fa[x] == x?x:fa[x] = find(fa[x]);
// }

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    vector<pi> st;
    for(int i = n; i >= 1; i--) {
        for(int j = i - 1; j >= 1; j--) {
            st.push_back({i, j});
        }
    }
    map<int, int> mp;
    for(int i = 1; i <= n; i++) b[i] = n + 1 - i, mp[n + 1 - i] = i;
    for(int i = 1; i <= n; i++) {
        int index = mp[a[i]];
        for(int j = index - 1; j >= i; j--) {
            st.push_back({b[j + 1], b[j]});
            swap(b[j + 1], b[j]);
        }
    }
    cout << st.size() << '\n';
    for(auto i: st) cout << i.first << ' ' << i.second << '\n';
}
int main()
{
  // 请在此输入您的代码
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
//     cin >> _;
    while(_--) solve();
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using ld = long double;
const int N = 1e6+ 10;
int mod = 1e9 + 7;
ll n,m;
ll a[N], b[N];
// int tree[N];
string s;
char c1,c2,c3;
priority_queue<ll, vector<ll>, greater<ll>> qmin;
priority_queue<ll> qmax;
ll max(ll aa, ll bb){return aa > bb?aa:bb;}
ll min(ll aa, ll bb){return aa < bb?aa:bb;}
ll qm(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = ret * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ret;
}
// int find(int x){
//     return fa[x] == x?x:fa[x] = find(fa[x]);
// }

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    vector<pi> st;
    for(int i = n; i >= 1; i--) {
        for(int j = i - 1; j >= 1; j--) {
            st.push_back({i, j});
        }
    }
    map<int, int> mp;
    for(int i = 1; i <= n; i++) b[i] = n + 1 - i, mp[n + 1 - i] = i;
    for(int i = 1; i <= n; i++) {
        int index = -1;
        for(int j = 1; j <= n; j++) if(b[j] == a[i]) index = j;
        for(int j = index - 1; j >= i; j--) {
            st.push_back({b[j + 1], b[j]});
            swap(b[j + 1], b[j]);
        }
    }
    cout << st.size() << '\n';
    for(auto i: st) cout << i.first << ' ' << i.second << '\n';
}
int main()
{
  // 请在此输入您的代码
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
//     cin >> _;
    while(_--) solve();
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define vpi vector<pair<int,int>>
#define mp make_pair
using namespace std;
const int inf = 1e18;
const int mod = 998244353;
int n,l,r;
void solve(){
    cin>>n>>l>>r;
    vi a(n);
    for(int i = 0; i < n; i++){
    	cin>>a[i];
	}
	sort(a.begin(), a.end());
	int res = 0;
	for(int i = 0; i <= r - l; i++){
		res += a[i];
	}
	cout<<res<<"\n";
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    cin>>T;
    while(T --){
        solve();
    }
    
    return 0;
} 
//    /\_/\
//   (= ._.)
//   / >  \>

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

#define int long long

#define vi vector<int>

#define vvi vector<vector<int>>

#define pi pair<int,int>

#define pii pair<pair<int,int>,int>

#define vpi vector<pair<int,int>>

#define mp make_pair

using namespace std;

const int inf = 1e18;

const int mod = 998244353;

int n,l,r;

void solve(){

    cin>>n>>l>>r;

    vi a, b;

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

    	int x;

    	cin>>x;

    	if(i <= r)a.push_back(x);

    	if(i >= l)b.push_back(x);

	}

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

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

	cout<<min(accumulate(a.begin(), a.begin() + (r - l + 1), 0), accumulate(b.begin(), b.begin() + (r - l + 1), 0))<<"\n";

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int T = 1;

    cin>>T;

    while(T --){

        solve();

    }

    

    return 0;

} 

//    /\_/\

//   (= ._.)

//   / >  \>
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define vpi vector<pair<int,int>>
#define mp make_pair
using namespace std;
const int inf = 1e18;
const int mod = 998244353;
int n,l,r;
void solve(){
    cin>>n>>l>>r;
    vi a(n);
    for(int i = 0; i < n; i++){
    	cin>>a[i];
	}
	sort(a.begin(), a.end());
	int res = 0;
	for(int i = 0; i <= r - l; i++){
		res += a[i];
	}
	cout<<res<<"\n";
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    cin>>T;
    while(T --){
        solve();
    }
    
    return 0;
} 
//    /\_/\
//   (= ._.)
//   / >  \>
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#define int long long

#define vi vector<int>

#define vvi vector<vector<int>>

#define pi pair<int,int>

#define pii pair<pair<int,int>,int>

#define vpi vector<pair<int,int>>

#define mp make_pair

using namespace std;

const int inf = 1e18;

const int mod = 998244353;

int n,l,r;

void solve(){

    cin>>n>>l>>r;

    vi a, b;

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

    	int x;

    	cin>>x;

    	if(i <= r)a.push_back(x);

    	if(i >= l)b.push_back(x);

	}

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

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

	cout<<min(accumulate(a.begin(), a.begin() + (r - l + 1), 0), accumulate(b.begin(), b.begin() + (r - l + 1), 0))<<"\n";

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int T = 1;

    cin>>T;

    while(T --){

        solve();

    }

    

    return 0;

} 

//    /\_/\

//   (= ._.)

//   / >  \>

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

#define int long long

#define vi vector<int>

#define vvi vector<vector<int>>

#define pi pair<int,int>

#define pii pair<pair<int,int>,int>

#define vpi vector<pair<int,int>>

#define mp make_pair

using namespace std;

const int inf = 1e18;

const int mod = 998244353;

int n,l,r;

void solve(){

    cin>>n>>l>>r;

    vi a, b;

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

    	int x;

    	cin>>x;

    	if(i <= r)a.push_back(x);

    	if(i >= l)b.push_back(x);

	}

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

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

	int sum1 = 0, sum2 = 0;

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

		sum1 += a[i];

		sum2 += b[i];

	}

	cout<<min(sum1, sum2)<<"\n";

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int T = 1;

    cin>>T;

    while(T --){

        solve();

    }

    

    return 0;

} 

//    /\_/\

//   (= ._.)

//   / >  \>
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
ll const N = 5e6 + 7;
#define fi first
#define se second
//ll lowbit(ll x){return x&-x;}
//ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//ll ksm(ll a,ll b,ll c){ll sum=1;while(b){if(b&1)sum=sum*a%c;a=a*a%c;b>>=1;}return sum;}
//ll to[N], ne[N], h[N], idx;void add(ll a, ll b) {to[++idx] = b;ne[idx] = h[a];h[a] = idx;}
//typedef pair<ll, ll>PII;
char arr[2000][2000];
ll vis[N];
//vector<ll>v;
//priority_queue<PII, vector<PII>, greater<PII>>q;
ll str[N];
ll  a,b, c, n, m, i, j, k, t,  ans = 0, cnt = 0, sum = 0, res = 0, flag, x, y, l, r;

void solve() {
	cin>>t;
	while(t--)
	{
		memset(vis,0,sizeof(vis));
		cin>>n;
		for(i=1;i<=n-1;i++)
		{
			cin>>a>>b;
//			add(a,b);
			vis[a]++;
			vis[b]++;
		}
		sort(vis+1,vis+n+1,greater<ll>());
		if(vis[1] == 1)
		vis[1] = 0;
		if(vis[2] == 1)
		vis[2] = 0;
		ans = vis[1] + vis[2] - 1;
		cout<<max(ans,0ll)<<"\n";
	} 
}

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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
ll const N = 5e6 + 7;
#define fi first
#define se second
//ll lowbit(ll x){return x&-x;}
//ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//ll ksm(ll a,ll b,ll c){ll sum=1;while(b){if(b&1)sum=sum*a%c;a=a*a%c;b>>=1;}return sum;}
//ll to[N], ne[N], h[N], idx;void add(ll a, ll b) {to[++idx] = b;ne[idx] = h[a];h[a] = idx;}
//typedef pair<ll, ll>PII;
char arr[2000][2000];
ll vis[N];
//vector<ll>v;
//priority_queue<PII, vector<PII>, greater<PII>>q;
ll str[N];
ll  a,b, c, n, m, i, j, k, t,  ans = 0, cnt = 0, sum = 0, res = 0, flag, x, y, l, r;

void solve() {
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(i=1;i<=n-1;i++)
		{
			cin>>a>>b;
//			add(a,b);
			vis[a]++;
			vis[b]++;
		}
		sort(vis+1,vis+n+1,greater<ll>());
		if(vis[1] == 1)
		vis[1] = 0;
		if(vis[2] == 1)
		vis[2] = 0;
		ans = vis[1] + vis[2] - 1;
		cout<<max(ans,0ll)<<"\n";
		for(i=1;i<=n;i++)
		vis[i] = 0;
	} 
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
ll const N = 5e6 + 7;
#define fi first
#define se second
//ll lowbit(ll x){return x&-x;}
//ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//ll ksm(ll a,ll b,ll c){ll sum=1;while(b){if(b&1)sum=sum*a%c;a=a*a%c;b>>=1;}return sum;}
ll to[N], ne[N], h[N], idx;void add(ll a, ll b) {to[++idx] = b;ne[idx] = h[a];h[a] = idx;}
//typedef pair<ll, ll>PII;
char arr[2000][2000];
ll vis[N];
//vector<ll>v;
//priority_queue<PII, vector<PII>, greater<PII>>q;
ll str[N];
ll  a,b, c, n, m, i, j, k, t,  ans = 0, cnt = 0, sum = 0, res = 0, flag, x, y, l, r;

void solve() {
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(i=1;i<=n;i++) h[i] = vis[i] = str[i] = ne[i] = to[i]= 0;
		idx = ans = 0;
		for(i=1;i<=n-1;i++)
		{
			cin>>a>>b;
			add(a,b);
			add(b,a);
			vis[a]++;
			vis[b]++;
		}
		if(n == 2)
		{
			cout<<"0\n";
			continue;
		}
		
		for(i=1;i<=n;i++)
		{
			str[i] = i;
			for(j=h[i];j;j = ne[j])
			{
				ans = max(ans, vis[i] + vis[to[j]] - 2);
				str[to[j]] = i;
			}
			for(j=1;j<=n;j++)
			{
				if(str[j]!=i)
				{
					ans = max(ans, vis[i] + vis[j] - 1);
				}
			}
		}
		cout<<ans<<"\n";
	} 
}

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

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
ll const N = 5e6 + 7;
#define fi first
#define se second
//ll lowbit(ll x){return x&-x;}
//ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//ll ksm(ll a,ll b,ll c){ll sum=1;while(b){if(b&1)sum=sum*a%c;a=a*a%c;b>>=1;}return sum;}
ll to[N], ne[N], h[N], idx;void add(ll a, ll b) {to[++idx] = b;ne[idx] = h[a];h[a] = idx;}
//typedef pair<ll, ll>PII;
char arr[2000][2000];
ll vis[N];
//vector<ll>v;
//priority_queue<PII, vector<PII>, greater<PII>>q;
ll str[N];
ll  a,b, c, n, m, i, j, k, t,  ans = 0, cnt = 0, sum = 0, res = 0, flag, x, y, l, r;

void solve() {
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(i=1;i<=n;i++) h[i] = vis[i] = str[i] = ne[i] = to[i]= 0;
		idx = ans = 0;
		for(i=1;i<=n-1;i++)
		{
			cin>>a>>b;
			add(a,b);
			add(b,a);
			vis[a]++;
			vis[b]++;
		}
		if(n == 2)
		{
			cout<<"0\n";
			continue;
		}
		
		for(i=1;i<=n;i++)
		{
			str[i] = i;
			for(j=h[i];j;j = ne[j])
			{
				ans = max(ans, vis[i] + vis[to[j]] - 2);
				str[to[j]] = i;
			}
			for(j=1;j<=n;j++)
			{
				if(str[j]!=i)
				{
					ans = max(ans, vis[i] + vis[j] - 1);
				}
			}
		}
		cout<<ans<<"\n";
	} 
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
ll const N = 5e6 + 7;
#define fi first
#define se second
//ll lowbit(ll x){return x&-x;}
//ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//ll ksm(ll a,ll b,ll c){ll sum=1;while(b){if(b&1)sum=sum*a%c;a=a*a%c;b>>=1;}return sum;}
ll to[N], ne[N], h[N], idx;void add(ll a, ll b) {to[++idx] = b;ne[idx] = h[a];h[a] = idx;}
//typedef pair<ll, ll>PII;
char arr[2000][2000];
ll vis[N];
//vector<ll>v;
//priority_queue<PII, vector<PII>, greater<PII>>q;
ll str[N];
ll  a,b, c, n, m, i, j, k, t,  ans = 0, cnt = 0, sum = 0, res = 0, flag, x, y, l, r;
ll p[N];
bool cmp(ll x,ll y)
{
	return vis[x]>vis[y];
}
void solve() {
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(i=1;i<=n;i++) h[i] = vis[i] = str[i] = ne[i] = to[i]= 0,p[i] = i;
		idx = ans = 0;
		for(i=1;i<=n-1;i++)
		{
			cin>>a>>b;
			add(a,b);
			add(b,a);
			vis[a]++;
			vis[b]++;
		}
		if(n == 2)
		{
			cout<<"0\n";
			continue;
		}
		sort(p+1,p+n+1,cmp);
		for(i=1;i<=n;i++)
		{
			str[i] = i;
			for(j=h[i];j;j = ne[j])
			{
				ans = max(ans, vis[i] + vis[to[j]] - 2);
				str[to[j]] = i;
			}
			for(j=1;j<=n;j++)
			{
				if(str[p[j]]!=i)
				{
					ans = max(ans, vis[i] + vis[p[j]] - 1);
					break;
				}
			}
		}
		cout<<ans<<"\n";
	} 
}

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

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
ll const N = 5e6 + 7;
#define fi first
#define se second
//ll lowbit(ll x){return x&-x;}
//ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//ll ksm(ll a,ll b,ll c){ll sum=1;while(b){if(b&1)sum=sum*a%c;a=a*a%c;b>>=1;}return sum;}
//ll to[N], ne[N], h[N], idx;void add(ll a, ll b) {to[++idx] = b;ne[idx] = h[a];h[a] = idx;}
//typedef pair<ll, ll>PII;
char arr[2000][2000];
ll vis[N];
//vector<ll>v;
//priority_queue<PII, vector<PII>, greater<PII>>q;
ll str[N];
ll  a,b, c, n, m, i, j, k, t,  ans = 0, cnt = 0, sum = 0, res = 0, flag, x, y, l, r;

void solve() {
	cin>>t;
	while(t--)
	{
		memset(vis,0,sizeof(vis));
		cin>>n;
		for(i=1;i<=n-1;i++)
		{
			cin>>a>>b;
//			add(a,b);
			vis[a]++;
			vis[b]++;
		}
		sort(vis+1,vis+n+1,greater<ll>());
		if(vis[1] == 1)
		vis[1] = 0;
		if(vis[2] == 1)
		vis[2] = 0;
		ans = vis[1] + vis[2] - 1;
		cout<<max(ans,0ll)<<"\n";
	} 
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
ll const N = 5e6 + 7;
#define fi first
#define se second
//ll lowbit(ll x){return x&-x;}
//ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//ll ksm(ll a,ll b,ll c){ll sum=1;while(b){if(b&1)sum=sum*a%c;a=a*a%c;b>>=1;}return sum;}
//ll to[N], ne[N], h[N], idx;void add(ll a, ll b) {to[++idx] = b;ne[idx] = h[a];h[a] = idx;}
//typedef pair<ll, ll>PII;
char arr[2000][2000];
ll vis[N];
//vector<ll>v;
//priority_queue<PII, vector<PII>, greater<PII>>q;
ll str[N];
ll  a,b, c, n, m, i, j, k, t,  ans = 0, cnt = 0, sum = 0, res = 0, flag, x, y, l, r;

void solve() {
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(i=1;i<=n-1;i++)
		{
			cin>>a>>b;
//			add(a,b);
			vis[a]++;
			vis[b]++;
		}
		sort(vis+1,vis+n+1,greater<ll>());
		if(vis[1] == 1)
		vis[1] = 0;
		if(vis[2] == 1)
		vis[2] = 0;
		ans = vis[1] + vis[2] - 1;
		cout<<max(ans,0ll)<<"\n";
		for(i=1;i<=n;i++)
		vis[i] = 0;
	} 
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	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>
#define int long long
using namespace std;
const int N=100010;
int l,r;
int a[3];
void solve(){
	memset(a,0,sizeof(a));
	cin>>l>>r;
	for(int i=30;i>=0;i--){
		sort(a,a+3);
		int x=1<<i;
		if(a[0]+x>r)continue;
		if(a[2]+x<=l){
			a[0]+=x;
			a[1]+=x;
			a[2]+=x;
			continue;
		}
		a[0]+=x;
		if(a[1]<l&&l<=a[1]+x&&a[1]+x<=r)a[1]+=x;
	}
	sort(a,a+3);
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<"\n";
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	return 0;
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int l,r;
int a[3];
void solve(){
	memset(a,0,sizeof(a));
	cin>>l>>r;
	int res=0;
	while(1){
		if(r-l==2){
			cout<<l+res<<" "<<l+res+1<<" "<<l+res+2<<"\n";
			return;
		}
		int x=1;
		while(x*2<=r)x<<=1;
		if(x<=l){
			res+=x;
			l-=x;
			r-=x;
			continue;
		}
		cout<<x+res<<" "<<x+res-1<<" "<<(x==r?l:r)<<"\n";
		break;
	}
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int l,r;
int a[3];
void solve(){
	memset(a,0,sizeof(a));
	cin>>l>>r;
	int res=0;
	while(1){
		if(r-l==2){
			cout<<l+res<<" "<<l+res+1<<" "<<l+res+2<<"\n";
			return;
		}
		int x=1;
		while(x*2<=r)x<<=1;
		if(x<=l){
			res+=x;
			l-=x;
			r-=x;
			continue;
		}
		cout<<x+res<<" "<<x+res-1<<" "<<(x==r?l:r)<<"\n";
		break;
	}
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int l,r;
int a[3];
void solve(){
	memset(a,0,sizeof(a));
	cin>>l>>r;
	int res=0;
	while(1){
		if(r-l==2){
			cout<<l+res<<" "<<l+res+1<<" "<<l+res+2<<"\n";
			return;
		}
		int x=1;
		while(x*2<=r)x<<=1;
		if(x<=l){
			res+=x;
			l-=x;
			r-=x;
			continue;
		}
		cout<<x+res<<" "<<x+res-1<<" "<<(x==r?l:r)+res<<"\n";
		break;
	}
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	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>
#define int long long
using namespace std;
const int N=100010;
int l,r;
int a[3];
void solve(){
	memset(a,0,sizeof(a));
	cin>>l>>r;
	for(int i=30;i>=0;i--){
		sort(a,a+3);
		int x=1<<i;
		if(a[0]+x>r)continue;
		if(a[2]+x<=l){
			a[0]+=x;
			a[1]+=x;
			a[2]+=x;
			continue;
		}
		a[0]+=x;
		if(a[1]<l&&l<=a[1]+x&&a[1]+x<=r)a[1]+=x;
	}
	sort(a,a+3);
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<"\n";
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("Ofast")

 

#include <bits/stdc++.h>

#ifndef ONLINE_JUDGE

#include "TemplateDebugging.cpp"

#else

#define debug(...)

#define debugArr(...)

#endif

 

using namespace std;

 

#define int long long

#define ull unsigned long long

#define ios ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);

#define F first

#define S second

#define pb push_back

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

#define maxelement(x) *max_element(all(x))

#define minelement(x) *min_element(all(x))

#define lb lower_bound

#define ub upper_bound

 

const int MAXN = 3e5 + 5;

const int MODO = 998244353;

const int MODI = 1234567891;

const int MOD = 1e9 + 7;

const int INF = 1e18;

 

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

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

 

// Think greedily



signed main(){

    ios;

    

    int t;

    cin >> t;

    while(t--){

        // 5 2 5

        // 3 3 2 3 5

        // 11



        // 5 2 5

        // 3 3 2 3 5

        

        int n, l, r;

        cin >> n >> l >> r;

        int x = r - l;



        vector<int> a(n);

        for(auto &i : a) cin >> i;

        sort(all(a));



        int final = 0;

        

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

            final += a[i];

        }



        cout << final << endl;

    }

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void solve(){
	ll l,r;
	scanf("%lld%lld",&l,&r);
	if (l==1&&r==3) {
		printf("1 2 3\n");
		return;
	}
	ll i=31,tmp=0;
	while (i>=0&&(l&(1ll<<i))==(r&(1ll<<i))) tmp=tmp|(r&(1ll<<i)),i--;
	ll a=tmp,b=tmp,c=tmp;
	a=a|(r&(1ll<<i));
	ll j=i;
	while (j>=0&&(l&(1ll<<j))==0) j--; 
	if (i-j==1) b=b|(1ll<<j); 
	for (i-=1;i>j;i--) b=b|(1ll<<i);
	while (j>=0) c=c|(1ll<<j),j--;
	printf("%lld %lld %lld\n",a,b,c);
}
int main(){
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}