ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define endl '\n'

#define int long long

const int inf = 0x7f7f7f7f;

const int mod = 1e9+7;



long long ksm(long long a,long long b){

	if(b==0) return 1;

	long long ans = 1;

	while(b>0){

		if(b & 1){

			ans= ans * a % mod;

		}

		a = a * a % mod;

		b>>=1;

	}

	return ans;

}



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vector<int> ans(n);

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

	{

       ans[(i+x)%n] = (i+1)%2;

	}

	if(n%2 || (y-x)%2==0)

	{

		ans[x] = 2;

	}

	for(auto t : ans)

		cout<<t<<" ";

	cout<<endl;



}



signed main(){

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	int t;

	cin>>t;

	while(t--){

		solve();

	}



	return 0;

}

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

using namespace std;

#define endl '\n'

#define int long long

const int inf = 0x7f7f7f7f;

const int mod = 1e9+7;



long long ksm(long long a,long long b){

	if(b==0) return 1;

	long long ans = 1;

	while(b>0){

		if(b & 1){

			ans= ans * a % mod;

		}

		a = a * a % mod;

		b>>=1;

	}

	return ans;

}



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vector<int> ans(n);

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

	{

       ans[(i+x)%n] = i%2;

	}

	if(n%2 || (y-x)%2==0)

	{

		ans[x] = 2;

	}

	for(auto t : ans)

		cout<<t<<" ";

	cout<<endl;



}



signed main(){

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	int t;

	cin>>t;

	while(t--){

		solve();

	}



	return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define lnf 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;

void work()
{
    int l,r;cin>>l>>r;
    int a=0,b = 0;
    int p =0 ;
    for(int i=30;i>=0;i--)
    {
        if((1<<i)&r);
        else
            continue;
        if(((1<<i)&l)&((1<<i)&r))
        {
            a+=(1<<i);
            b+=(1<<i);
        }
        else
        {
            p = i;
        }
    }
    b+=(1<<p);
    p-=1;
    for(int i = p;i>=0;i--)
    {
        a+=(1<<i);
    }
    if(r==a||r==b)
        cout<<a<<" "<<b<<" "<<l<<"\n";
    else
        cout<<a<<" "<<b<<" "<<r<<"\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T = 1;
    cin>>T;
    while(T--)
        work();

    return 0;
}

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

void work()
{
    int l,r;cin>>l>>r;
    int a=0,b = 0;
    int p =0 ;
    for(int i=30;i>=0;i--)
    {
        if((1<<i)&r);
        else
            continue;
        if(((1<<i)&l)&((1<<i)&r))
        {
            a+=(1<<i);
            b+=(1<<i);
        }
        else
        {
            p = i;
            break;
        }
    }
    b+=(1<<p);
    p-=1;
    for(int i = p;i>=0;i--)
    {
        a+=(1<<i);
    }
    if(r==a||r==b)
        cout<<a<<" "<<b<<" "<<l<<"\n";
    else
        cout<<a<<" "<<b<<" "<<r<<"\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T = 1;
    cin>>T;
    while(T--)
        work();

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define lnf 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;

void work()
{
    int l,r;cin>>l>>r;
    int a=0,b = 0;
    int p =0 ;
    for(int i=30;i>=0;i--)
    {
        if(((1<<i)&l)&((1<<i)&r))
        {
            a+=(1<<i);
            b+=(1<<i);
        }
        else
        {
            p = i;
        }
    }
    b+=(1<<p);
    p-=1;
    for(int i = p;i>=0;i--)
    {
        a+=(1<<i);
    }
    if(r==a||r==b)
        cout<<a<<" "<<b<<" "<<l<<"\n";
    else
        cout<<a<<" "<<b<<" "<<r<<"\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T = 1;
    cin>>T;
    while(T--)
        work();

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define lnf 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;

void work()
{
    int l,r;cin>>l>>r;
    int a=0,b = 0;
    int p =0 ;
    for(int i=30;i>=0;i--)
    {
        if(((1<<i)&l)&((1<<i)&r))
        {
            a+=(1<<i);
            b+=(1<<i);
        }
        else
        {
            p = i;
        }
    }
    b+=(1<<p);
    p-=1;
    for(int i = p;i>=0;i--)
    {
        a+=(1<<i);
    }
    if(r==a||r==b)
        cout<<a<<" "<<b<<" "<<l<<"\n";
    else
        cout<<a<<" "<<b<<" "<<r<<"\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T = 1;
    cin>>T;
    while(T--)
        work();

    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define lnf 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;

void work()
{
    int l,r;cin>>l>>r;
    int a=0,b = 0;
    int p =0 ;
    for(int i=30;i>=0;i--)
    {
        if((1<<i)&r);
        else
            continue;
        if(((1<<i)&l)&((1<<i)&r))
        {
            a+=(1<<i);
            b+=(1<<i);
        }
        else
        {
            p = i;
        }
    }
    b+=(1<<p);
    p-=1;
    for(int i = p;i>=0;i--)
    {
        a+=(1<<i);
    }
    if(r==a||r==b)
        cout<<a<<" "<<b<<" "<<l<<"\n";
    else
        cout<<a<<" "<<b<<" "<<r<<"\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T = 1;
    cin>>T;
    while(T--)
        work();

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;
typedef map<int, int> mi;
typedef set<int, greater<int>> si;
int n, m;
int newn, newm;
mi amap, bmap;
vi a, b;
si sa, sb;

void solve() {
  cin >> n >> m;
  a.assign(n, 0); b.assign(m, 0);
  amap.clear(), bmap.clear();
  sa.clear(), sb.clear();
  for (int i = 0; i < n; ++i) { cin >> a[i]; ++amap[a[i]]; sa.insert(a[i]); }
  for (int i = 0; i < m; ++i) { cin >> b[i]; ++bmap[b[i]]; sb.insert(b[i]); }

  sort(b.begin(), b.end(), greater<int>());
  int count = n - m;
  for (int i = 0; i < count; ++i) {
    //cout << i << ", " << b[j] << ":" << bmap[b[j]] << " " << amap[b[j]] << endl;
    int bval = *sb.begin();
    if (bval == 1) break;
    if (bmap[bval] != amap[bval]) {
      ++bmap[floor(bval/2.0f)];
      ++bmap[ceil(bval/2.0f)];
      --bmap[bval];
      if (bmap[bval] == 0) sb.erase(sb.begin());
      sb.insert(ceil(bval/2.0f));
      sb.insert(floor(bval/2.0f));
      //for (auto s : sb) { cout << s << " " ; }
      //cout << endl;
    } else { sb.erase(sb.begin()); --i; }
  }

  int ans = 1;
  for (const auto &[key, val] : bmap) {
    //cout << key << " " << val << endl;
    if (val != amap[key]) { ans = 0; break; }
  }
  for (const auto &[key, val] : amap) {
    //cout << key << " " << val << endl;
    if (val != bmap[key]) { ans = 0; break; }
  }

  cout << (ans ? "YES" : "NO") << endl;
}

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


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

using namespace std;
typedef vector<int> vi;
typedef map<int, int> mi;
typedef set<int, greater<int>> si;
int n, m;
int newn, newm;
mi amap, bmap;
vi a, b;
si sa, sb;

void solve() {
  cin >> n >> m;
  a.assign(n, 0); b.assign(m, 0);
  amap.clear(), bmap.clear();
  sa.clear(), sb.clear();
  for (int i = 0; i < n; ++i) { cin >> a[i]; ++amap[a[i]]; sa.insert(a[i]); }
  for (int i = 0; i < m; ++i) { cin >> b[i]; ++bmap[b[i]]; sb.insert(b[i]); }

  sort(b.begin(), b.end(), greater<int>());
  int count = n - m;
  for (int i = 0; i < count; ++i) {
    //cout << i << ", " << b[j] << ":" << bmap[b[j]] << " " << amap[b[j]] << endl;
    if (sb.empty()) break;
    int bval = *sb.begin();
    if (bval == 1) break;
    if (bmap[bval] != amap[bval]) {
      ++bmap[floor(bval/2.0f)];
      ++bmap[ceil(bval/2.0f)];
      --bmap[bval];
      if (bmap[bval] == 0) sb.erase(sb.begin());
      sb.insert(ceil(bval/2.0f));
      sb.insert(floor(bval/2.0f));
      //for (auto s : sb) { cout << s << " " ; }
      //cout << endl;
    } else { sb.erase(sb.begin()); --i; }
  }

  int ans = 1;
  for (const auto &[key, val] : bmap) {
    //cout << key << " " << val << endl;
    if (val != amap[key]) { ans = 0; break; }
  }
  for (const auto &[key, val] : amap) {
    //cout << key << " " << val << endl;
    if (val != bmap[key]) { ans = 0; break; }
  }

  cout << (ans ? "YES" : "NO") << endl;
}

int main() {
  int t; cin >> t;
  while(t--) {
    solve();
  }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

using namespace std;
typedef vector<int> vi;
typedef map<int, int> mi;
int n, m;
int newn, newm;
mi amap, bmap;
vi a, b;

void solve() {
  cin >> n >> m;
  a.assign(n, 0); b.assign(m, 0);
  amap.clear(), bmap.clear();
  for (int i = 0; i < n; ++i) { cin >> a[i]; ++amap[a[i]]; }
  for (int i = 0; i < m; ++i) { cin >> b[i]; ++bmap[b[i]]; }

  sort(b.begin(), b.end(), greater<int>());
  int j = 0;
  int count = n - m;
  for (int i = 0; i < count; ++i) {
    //cout << i << ", " << b[j] << ":" << bmap[b[j]] << " " << amap[b[j]] << endl;
    if (j >= m || b[j] == 1) break;
    if (bmap[b[j]] != amap[b[j]]) {
      ++bmap[floor(b[j]/2.0f)];
      ++bmap[ceil(b[j]/2.0f)];
      --bmap[b[j]];
      b.insert(upper_bound(b.begin(), b.end(), ceil(b[j]/2.0f), greater<>()), ceil(b[j]/2.0f));
      b.insert(upper_bound(b.begin(), b.end(), floor(b[j]/2.0f), greater<>()), floor(b[j]/2.0f));
      ++m; ++m;
      //for (int k = 0; k < m; ++k) { cout << b[k] << " "; }
      //cout << endl;
    } else { --i; }
    ++j;
  }

  int ans = 1;
  for (const auto &[key, val] : bmap) {
    //cout << key << " " << val << endl;
    if (val != amap[key]) { ans = 0; break; }
  }
  cout << (ans ? "YES" : "NO") << endl;
}

int main() {
  int t; cin >> t;
  while(t--) {
    solve();
  }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 19):
#include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;
typedef map<int, int> mi;
int n, m;
int newn, newm;
mi amap, bmap;
vi a, b;

void solve() {
  cin >> n >> m;
  a.assign(n, 0); b.assign(m, 0);
  amap.clear(), bmap.clear();
  for (int i = 0; i < n; ++i) { cin >> a[i]; ++amap[a[i]]; }
  for (int i = 0; i < m; ++i) { cin >> b[i]; ++bmap[b[i]]; }

  sort(b.begin(), b.end(), greater<int>());
  int j = 0;
  int count = n - m;
  for (int i = 0; i < count; ++i) {
    //cout << i << ", " << b[j] << ":" << bmap[b[j]] << " " << amap[b[j]] << endl;
    if (j >= m || b[j] == 1) break;
    if (bmap[b[j]] != amap[b[j]]) {
      ++bmap[floor(b[j]/2.0f)];
      ++bmap[ceil(b[j]/2.0f)];
      --bmap[b[j]];
      b.insert(upper_bound(b.begin(), b.end(), ceil(b[j]/2.0f), greater<>()), ceil(b[j]/2.0f));
      b.insert(upper_bound(b.begin(), b.end(), floor(b[j]/2.0f), greater<>()), floor(b[j]/2.0f));
      ++m; ++m;
      //for (int k = 0; k < m; ++k) { cout << b[k] << " "; }
      //cout << endl;
    } else { --i; }
    ++j;
  }

  int ans = 1;
  for (const auto &[key, val] : bmap) {
    //cout << key << " " << val << endl;
    if (val != amap[key]) { ans = 0; break; }
  }
  for (const auto &[key, val] : amap) {
    //cout << key << " " << val << endl;
    if (val != bmap[key]) { ans = 0; break; }
  }

  cout << (ans ? "YES" : "NO") << endl;
}

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


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;
typedef map<int, int> mi;
typedef set<int, greater<int>> si;
int n, m;
int newn, newm;
mi amap, bmap;
vi a, b;
si sa, sb;

void solve() {
  cin >> n >> m;
  a.assign(n, 0); b.assign(m, 0);
  amap.clear(), bmap.clear();
  sa.clear(), sb.clear();
  for (int i = 0; i < n; ++i) { cin >> a[i]; ++amap[a[i]]; sa.insert(a[i]); }
  for (int i = 0; i < m; ++i) { cin >> b[i]; ++bmap[b[i]]; sb.insert(b[i]); }

  sort(b.begin(), b.end(), greater<int>());
  int count = n - m;
  for (int i = 0; i < count; ++i) {
    //cout << i << ", " << b[j] << ":" << bmap[b[j]] << " " << amap[b[j]] << endl;
    int bval = *sb.begin();
    if (bval == 1) break;
    if (bmap[bval] != amap[bval]) {
      ++bmap[floor(bval/2.0f)];
      ++bmap[ceil(bval/2.0f)];
      --bmap[bval];
      if (bmap[bval] == 0) sb.erase(sb.begin());
      sb.insert(ceil(bval/2.0f));
      sb.insert(floor(bval/2.0f));
      //for (auto s : sb) { cout << s << " " ; }
      //cout << endl;
    } else { sb.erase(sb.begin()); --i; }
  }

  int ans = 1;
  for (const auto &[key, val] : bmap) {
    //cout << key << " " << val << endl;
    if (val != amap[key]) { ans = 0; break; }
  }
  for (const auto &[key, val] : amap) {
    //cout << key << " " << val << endl;
    if (val != bmap[key]) { ans = 0; break; }
  }

  cout << (ans ? "YES" : "NO") << endl;
}

int main() {
  int t; cin >> t;
  while(t--) {
    solve();
  }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

using namespace std;
typedef vector<int> vi;
typedef map<int, int> mi;
int n, m;
int newn, newm;
mi amap, bmap;
vi a, b;

void solve() {
  cin >> n >> m;
  a.assign(n, 0); b.assign(m, 0);
  amap.clear(), bmap.clear();
  for (int i = 0; i < n; ++i) { cin >> a[i]; ++amap[a[i]]; }
  for (int i = 0; i < m; ++i) { cin >> b[i]; ++bmap[b[i]]; }

  sort(b.begin(), b.end(), greater<int>());
  int j = 0;
  int count = n - m;
  for (int i = 0; i < count; ++i) {
    //cout << i << ", " << b[j] << ":" << bmap[b[j]] << " " << amap[b[j]] << endl;
    if (j >= m || b[j] == 1) break;
    if (bmap[b[j]] != amap[b[j]]) {
      ++bmap[floor(b[j]/2.0f)];
      ++bmap[ceil(b[j]/2.0f)];
      --bmap[b[j]];
      b.insert(upper_bound(b.begin(), b.end(), ceil(b[j]/2.0f), greater<>()), ceil(b[j]/2.0f));
      b.insert(upper_bound(b.begin(), b.end(), floor(b[j]/2.0f), greater<>()), floor(b[j]/2.0f));
      ++m; ++m;
      //for (int k = 0; k < m; ++k) { cout << b[k] << " "; }
      //cout << endl;
    } else { --i; }
    ++j;
  }

  int ans = 1;
  for (const auto &[key, val] : bmap) {
    //cout << key << " " << val << endl;
    if (val != amap[key]) { ans = 0; break; }
  }
  cout << (ans ? "YES" : "NO") << endl;
}

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


Submission (verdict: Time limit exceeded on test 19):
#include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;
typedef map<int, int> mi;
int n, m;
int newn, newm;
mi amap, bmap;
vi a, b;

void solve() {
  cin >> n >> m;
  a.assign(n, 0); b.assign(m, 0);
  amap.clear(), bmap.clear();
  for (int i = 0; i < n; ++i) { cin >> a[i]; ++amap[a[i]]; }
  for (int i = 0; i < m; ++i) { cin >> b[i]; ++bmap[b[i]]; }

  sort(b.begin(), b.end(), greater<int>());
  int j = 0;
  int count = n - m;
  for (int i = 0; i < count; ++i) {
    //cout << i << ", " << b[j] << ":" << bmap[b[j]] << " " << amap[b[j]] << endl;
    if (j >= m || b[j] == 1) break;
    if (bmap[b[j]] != amap[b[j]]) {
      ++bmap[floor(b[j]/2.0f)];
      ++bmap[ceil(b[j]/2.0f)];
      --bmap[b[j]];
      b.insert(upper_bound(b.begin(), b.end(), ceil(b[j]/2.0f), greater<>()), ceil(b[j]/2.0f));
      b.insert(upper_bound(b.begin(), b.end(), floor(b[j]/2.0f), greater<>()), floor(b[j]/2.0f));
      ++m; ++m;
      //for (int k = 0; k < m; ++k) { cout << b[k] << " "; }
      //cout << endl;
    } else { --i; }
    ++j;
  }

  int ans = 1;
  for (const auto &[key, val] : bmap) {
    //cout << key << " " << val << endl;
    if (val != amap[key]) { ans = 0; break; }
  }
  for (const auto &[key, val] : amap) {
    //cout << key << " " << val << endl;
    if (val != bmap[key]) { ans = 0; break; }
  }

  cout << (ans ? "YES" : "NO") << endl;
}

int main() {
  int t; cin >> t;
  while(t--) {
    solve();
  }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int a[N];
int t;
int main()
{
	cin >> t;
	while(t --)
	{
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		LL ans = 0;
		sort(a + 1, a + 1 + n);
		for(int i = 1; i <= r - l + 1; i ++)
		{
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int a[N];
int t;
int main()
{
	cin >> t;
	while(t --)
	{
		memset(a, 0, sizeof(a));
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		LL ans = 0;
		sort(a + 1, a + 1 + n);
		for(int i = 1; i <= r - l + 1; i ++)
		{
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N];
int t;
int main()
{
	cin >> t;
	while(t --)
	{
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		int ans = 0;
		sort(a + 1, a + 1 + n);
		for(int i = 1; i <= r - l + 1; i ++)
		{
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N];
int t;
int main()
{
	cin >> t;
	while(t --)
	{
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		int ans = 0;
		sort(a + 1, a + 1 + n);
		for(int i = 1; i <= r - l + 1; i ++)
		{
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int a[N];
int t;
int main()
{
	cin >> t;
	while(t --)
	{
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		LL ans = 0;
		sort(a + 1, a + 1 + n);
		for(int i = 1; i <= r - l + 1; i ++)
		{
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int a[N];
int b[N];
int t;
bool cmp(int a, int b)
{
	return a > b;
}
int main()
{
	cin >> t;
	while(t --)
	{
		memset(a, 0, sizeof(a));
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
			b[i] =a[i];
		}
		LL ans = 0;
		sort(a + 1, a + 1 + r, cmp);
		sort(b + 1 + l, b + 1 + n);
		for(int i = l; i <= r; i++)
		{
			ans += a[i];
		}
		LL ans2 = 0;
		for(int i = l; i <= r; i++)
		{
			ans2 += b[i];
		}
		cout << min(ans, ans2) << endl;
	}
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int a[N];
int b[N];
int t;
bool cmp(int a, int b)
{
	return a > b;
}
int main()
{
	cin >> t;
	while(t --)
	{
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
			b[i] =a[i];
		}
		LL ans = 0;
		sort(a + 1, a + 1 + r, cmp);
		sort(b + l, b + 1 + n);
		for(int i = l; i <= r; i++)
		{
			ans += a[i];
		}
		LL ans2 = 0;
		for(int i = l; i <= r; i++)
		{
			ans2 += b[i];
		}
		cout << min(ans, ans2) << endl;
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int a[N];
int t;
int main()
{
	cin >> t;
	while(t --)
	{
		memset(a, 0, sizeof(a));
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		LL ans = 0;
		sort(a + 1, a + 1 + n);
		for(int i = 1; i <= r - l + 1; i ++)
		{
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int a[N];
int b[N];
int t;
bool cmp(int a, int b)
{
	return a > b;
}
int main()
{
	cin >> t;
	while(t --)
	{
		memset(a, 0, sizeof(a));
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i];
			b[i] =a[i];
		}
		LL ans = 0;
		sort(a + 1, a + 1 + r, cmp);
		sort(b + 1 + l, b + 1 + n);
		for(int i = l; i <= r; i++)
		{
			ans += a[i];
		}
		LL ans2 = 0;
		for(int i = l; i <= r; i++)
		{
			ans2 += b[i];
		}
		cout << min(ans, ans2) << endl;
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

const int N = 55;
int a[N];
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll ans = 0;
	if (n == 1) {
		cout << a[1] << endl;
		return;
	}
	while (n > 1) {
		ll res = 0;
		for (int i = 1; i <= n; ++i) {
			res += a[i];
		}
		ans = max(res, ans);
		res = 0;
		for (int i = 1; i < n; ++i) {
			a[i] = a[i + 1] - a[i];
			res += a[i];
		}
		ans = max(abs(res), ans);
		n--;
	}
	cout << ans << endl;
	return;
}

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

Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

const int N = 55;
ll a[N];
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll ans = 0;
	if (n == 1) {
		cout << a[1] << endl;
		return;
	}
	while (n > 1) {
		ll res = 0;
		for (int i = 1; i <= n; ++i) {
			res += a[i];
		}
		ans = max(res, ans);
		res = 0;
		for (int i = 1; i < n; ++i) {
			a[i] = a[i + 1] - a[i];
			res += a[i];
		}
		ans = max(abs(res), ans);
		n--;
	}
	cout << ans << endl;
	return;
}

int main() {
	int t;
	cin >> t;
	while (t--)solve();
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

const int N = 55;
int a[N];
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll ans = 0;
	while (n > 1) {
		ll res = 0;
		for (int i = 1; i <= n; ++i) {
			res += a[i];
		}
		ans = max(res, ans);
		res = 0;
		for (int i = 1; i < n; ++i) {
			a[i] = a[i + 1] - a[i];
			res += a[i];
		}
		ans = max(abs(res), ans);
		n--;
	}
	cout << ans << endl;
	return;
}

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