ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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


#define ll long long int
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const ll INF = 1e18;


template<typename T>
void debug(vector<T> v) { for(auto i: v) cout << i << " "; cout << endl; }

template<typename T1, typename T2>
void debug(vector<pair<T1, T2>> v) { for(auto i: v) cout << "(" << i.F << "," << i.S << ") "; cout << endl; }


int main() {
    fast_io;

    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<vector<int>>neighbours(n,vector<int>());
        vector<int>deg(n,0);
        for(int i=0;i<n-1;i++){
            int a,b;
            cin>>a>>b;
            neighbours[a-1].push_back(b-1);
            neighbours[b-1].push_back(a-1);
            deg[a-1]++;
            deg[b-1]++;
        }
        int maxi = 0;
        int conn = 1;
        for(int i =1;i<n;i++){
            if(deg[maxi]  < deg[i] ){
                maxi = i;
            }
        }
        for(auto e:neighbours[maxi]){
            deg[e]--;
        }
        conn = conn -1 + deg[maxi];
        deg[maxi] = INT_MIN;

        
        maxi = 0;
        for(int i =1;i<n;i++){
            if(deg[maxi]  < deg[i] ){
                maxi = i;
            }
        }
        conn = conn -1 + deg[maxi];

        cout<<conn<<endl;


        
    }

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


Submission (verdict: Wrong answer on test 1):
/* -------------------------------------- HEADER FILES ---------------------------------------- */

/**
 *    username:  aditya_0670
 *    created: 2025-01-04 01:53:22
 **/

  #include <bits/stdc++.h>
  using namespace std;

/* ------------------------------------ MACROS & CONSTANTS ------------------------------------ */

  #ifndef ONLINE_JUDGE
      #include "debug.h"
  #else
      #define debug(...) ;
  #endif

  #define int             long long
  #define all(v)          (v).begin(), (v).end()
  #define rall(v)         (v).rbegin(), (v).rend()
  #define fastio          ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

  constexpr int MOD = 1E9 + 7;
  constexpr int INF = 1E18;


/* ------------------------------------ OTHER FUNCTIONS ------------------------------------ */


/* ------------------------------------ LAMBDA TEMPLATE ------------------------------------- */

  auto solve = [] -> void
  {
      int l, r; cin >> l >> r;

      int a = 0, b = 0, c = 0;
      for (int i = 29; i >= 0; i--)
      {
          if (((l >> i) & 1) == ((r >> i) & 1)) 
          {
              a |= (l & (1 << i));
              b |= (l & (1 << i));
          }
          else 
          {
             a |= (1 << i);
             b |= ((1 << i) - 1);
             break;
          }
      }

      cout << (b ^ 1) << ' ' << b << ' ' << a << '\n';
  };

/* ------------------------------------ MAIN FUNCTION --------------------------------------- */

  signed main() 
  {
      fastio;

      int t = 1;
      cin >> t;
      while (t--) solve();

      return 0;
  }
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

int main()
{
    int l,t;
    cin>>t;
    while(t--){
    cin>>l;
    int arr[l];
    int s=0;
    for(int i=0;i<l;i++) cin>>arr[i];
    for(int i=0;i<l;i++) s=s+arr[i];
    int s1=0;
    while(l>1){
        s1=abs(arr[l-1]-arr[0]);
        if(s1>s) s=s1;
        for(int i=0;i<l-1;i++) arr[i]=arr[i+1]-arr[i];
        l--;
    }
    cout<<s<<"\n";
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int main()
{
    int l,t;
    cin>>t;
    while(t--){
    cin>>l;
    int arr[l];
    long long int s=0;
    for(int i=0;i<l;i++) cin>>arr[i];
    for(int i=0;i<l;i++) s=s+arr[i];
    long long int s1=0;
    while(l>1){
        s1=abs(arr[l-1]-arr[0]);
        if(s1>s) s=s1;
        for(int i=0;i<l-1;i++) arr[i]=arr[i+1]-arr[i];
        l--;
    }
    cout<<s<<"\n";
    }

    return 0;
}

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

int main()
{
    int l,t;
    cin>>t;
    while(t--){
    cin>>l;
    long long int arr[l];
    long long int s=0;
    for(int i=0;i<l;i++) cin>>arr[i];
    for(int i=0;i<l;i++) s=s+arr[i];
    long long int s1=0;
    while(l>1){
        s1=abs(arr[l-1]-arr[0]);
        if(s1>s) s=s1;
        for(int i=0;i<l-1;i++) arr[i]=arr[i+1]-arr[i];
        l--;
    }
    cout<<s<<"\n";
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int main()
{
    int l,t;
    cin>>t;
    while(t--){
    cin>>l;
    int arr[l];
    int s=0;
    for(int i=0;i<l;i++) cin>>arr[i];
    for(int i=0;i<l;i++) s=s+arr[i];
    int s1=0;
    while(l>1){
        s1=abs(arr[l-1]-arr[0]);
        if(s1>s) s=s1;
        for(int i=0;i<l-1;i++) arr[i]=arr[i+1]-arr[i];
        l--;
    }
    cout<<s<<"\n";
    }

    return 0;
}

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

int main()
{
    int l,t;
    cin>>t;
    while(t--){
    cin>>l;
    int arr[l];
    long long int s=0;
    for(int i=0;i<l;i++) cin>>arr[i];
    for(int i=0;i<l;i++) s=s+arr[i];
    long long int s1=0;
    while(l>1){
        s1=abs(arr[l-1]-arr[0]);
        if(s1>s) s=s1;
        for(int i=0;i<l-1;i++) arr[i]=arr[i+1]-arr[i];
        l--;
    }
    cout<<s<<"\n";
    }

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

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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
       int l,r;
       cin>>l>>r;
       cout<<r<<" "<<r<<" "<<r<<"\n";
    }
    // your code goes here

}

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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int l, r;
        cin >> l >> r;
        int a = 0, b = 0, c = 0, pos;
        for (int i = 30; i >= 0; i--) {
            int bit = (1 << i);
            if ((l & b) != (r & b)) {
                pos = i;
                break;
            }
        }

        a = l | ((1 << pos) - 1);
        b = a + 1;
        c = r;

        if (c == a || c == b) {
            c--;
        }
        if (c == a || c == b) {
            c--;
        }
        cout << a << " " << b << " " << c << "\n";

    }
    // your code goes here

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


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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
       int l,r;
       cin>>l>>r;
       cout<<r<<" "<<r<<" "<<r<<"\n";
    }
    // your code goes here

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

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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int l, r;
        cin >> l >> r;
        int a = 0, b = 0, c = 0, pos;
        for (int i = 30; i >= 0; i--) {
            int bit = (1LL << i);
            if ((l & b) ^ (r & b)) {
                pos = i;
                break;
            }
        }

        a = l | ((1LL << pos) - 1);
        b = a + 1;
        c = r;

        if (c == a || c == b) {
            c--;
        }
        if (c == a || c == b) {
            c--;
        }
        cout << a << " " << b << " " << c << "\n";

    }
    // your code goes here

}

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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int l, r;
        cin >> l >> r;
        int k = 32 - __builtin_clz(l ^ r);
        int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
        cout << a << " " << b << " " << c << "\n";

    }
    // your code goes here

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

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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int l, r;
        cin >> l >> r;
        int a = 0, b = 0, c = 0, pos;
        for (int i = 30; i >= 0; i--) {
            int bit = (1 << i);
            if ((l & b) != (r & b)) {
                pos = i;
                break;
            }
        }

        a = l | ((1 << pos) - 1);
        b = a + 1;
        c = r;

        if (c == a || c == b) {
            c--;
        }
        if (c == a || c == b) {
            c--;
        }
        cout << a << " " << b << " " << c << "\n";

    }
    // your code goes here

}

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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int l, r;
        cin >> l >> r;
        int a = 0, b = 0, c = 0, pos;
        for (int i = 30; i >= 0; i--) {
            int bit = (1LL << i);
            if ((l & b) ^ (r & b)) {
                pos = i;
                break;
            }
        }

        a = l | ((1LL << pos) - 1);
        b = a + 1;
        c = r;

        if (c == a || c == b) {
            c--;
        }
        if (c == a || c == b) {
            c--;
        }
        cout << a << " " << b << " " << c << "\n";

    }
    // your code goes here

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

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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int l, r;
        cin >> l >> r;
        int k = 32 - __builtin_clz(l ^ r);
        int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
        cout << a << " " << b << " " << c << "\n";

    }
    // your code goes here

}

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

using namespace std;
#define int long long int
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int l, r;
        cin >> l >> r;
        int k = 31 - __builtin_clz(l ^ r);
        int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
        cout << a << " " << b << " " << c << "\n";

    }
    // your code goes here

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;

int main(){

int t; cin>>t;

while(t--){

int n; cin>>n;

vector<int> v(n);

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

int j = 0;

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

if(v[i-1]>v[i]) j = i;

}

if(j == 0) cout<<"YES"<<endl;

else{

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

for(int k = 0; k<n-1; k++){

int temp = min(v[k], v[k+1]);

v[k] -= temp;

v[k+1] -= temp;

}

}

if(is_sorted(v.begin(), v.end())) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

}

}

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

using namespace std;

int main(){

long long t; cin>>t;

while(t--){

long long n; cin>>n;

vector<long long> v(n);

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

long long j = 0;

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

if(v[i-1]>v[i]) j = i;

}

if(j == 0) cout<<"YES"<<endl;

else{

for(long long i = 0; i<j; i++){

for(long long k = 0; k<n-1; k++){

long long temp = min(v[k], v[k+1]);

v[k] -= temp;

v[k+1] -= temp;

}

}

if(is_sorted(v.begin(), v.end())) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

}

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;

int main(){

int t; cin>>t;

while(t--){

int n; cin>>n;

vector<int> v(n);

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

if(v[n-1]>v[n-2]) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

}

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

using namespace std;

int main(){

int t; cin>>t;

while(t--){

int n; cin>>n;

vector<int> v(n);

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

int j = 0;

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

if(v[i-1]>v[i]) j = i;

}

if(j == 0) cout<<"YES"<<endl;

else{

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

for(int k = 0; k<n-1; k++){

int temp = min(v[k], v[k+1]);

v[k] -= temp;

v[k+1] -= temp;

}

}

if(is_sorted(v.begin(), v.end())) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

}

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;

int main(){

long long t; cin>>t;

while(t--){

long long n; cin>>n;

vector<long long> v(n);

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

long long j = 0;

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

if(v[i-1]>v[i]) j = i;

}

if(j == 0) cout<<"YES"<<endl;

else{

for(long long i = 0; i<j; i++){

for(long long k = 0; k<n-1; k++){

long long temp = min(v[k], v[k+1]);

v[k] -= temp;

v[k+1] -= temp;

}

}

if(is_sorted(v.begin(), v.end())) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

}

}

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

using namespace std;

int main(){

long long t; cin>>t;

while(t--){

long long n; cin>>n;

vector<long long> v(n);

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

long long j = 0;

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

if(v[i-1]>v[i]) j = i;

}

if(j == 0) cout<<"YES"<<endl;

else{

for(long long i = 0; i<j; i++){

long long temp = min(v[i], v[i+1]);

v[i] -= temp;

v[i+1] -= temp;

}

if(is_sorted(v.begin(), v.end())) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

}

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

using namespace std;

int main(){

int t; cin>>t;

while(t--){

int n; cin>>n;

vector<int> v(n);

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

if(v[n-1]>v[n-2]) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

#define int long long

using namespace std;



int a[200005];



signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

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

cin>>a[i];

//TODO

}

int ok=0;

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

if(a[i]>a[i+1]){

if(a[i]-min(a[i],a[i-1])<=a[i+1]){

a[i]-=min(a[i],a[i-1]);

continue;

//TODO

}else{

ok=1;

}

//TODO

}

//TODO

}

if(ok){

cout<<"NO"<<endl;

//TODO

}else{

cout<<"YES"<<endl;

}



}



return 0;

}

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

#define int long long

using namespace std;



int a[200005];



signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

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

cin>>a[i];

//TODO

}

int ok=0;

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

if(a[i+1]-a[i]<a[i+2]){

int minn=min(a[i],a[i+1]);

a[i]-=minn,a[i+1]-=minn;

//TODO

}

//TODO

}



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

if(a[i]>a[i+1]){

ok=1;

//TODO

}

//TODO

}



if(ok){

cout<<"NO"<<endl;

//TODO

}else{

cout<<"YES"<<endl;

}



}



return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

#define int long long

using namespace std;



int a[200005];



signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

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

cin>>a[i];

//TODO

}

int ok=0;

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

if(a[i]>a[i+1]){

if(a[i]-min(a[i],a[i-1])<=a[i+1]){

a[i]-=min(a[i],a[i-1]);

continue;

//TODO

}else{

ok=1;

}

//TODO

}

//TODO

}

if(ok){

cout<<"NO"<<endl;

//TODO

}else{

cout<<"YES"<<endl;

}



}



return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

#define int long long

using namespace std;



int a[200005];



signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

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

cin>>a[i];

//TODO

}

int ok=0;

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

if(a[i+1]-a[i]<a[i+2]){

int minn=min(a[i],a[i+1]);

a[i]-=minn,a[i+1]-=minn;

//TODO

}

//TODO

}



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

if(a[i]>a[i+1]){

ok=1;

//TODO

}

//TODO

}



if(ok){

cout<<"NO"<<endl;

//TODO

}else{

cout<<"YES"<<endl;

}



}



return 0;

}

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

#define int long long

using namespace std;



int a[200005];



signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

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

cin>>a[i];

//TODO

}

int ok=0;

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

if(a[i+1]-a[i]<a[i+2]&&a[i]<=a[i+1]){

int minn=min(a[i],a[i+1]);

a[i]-=minn,a[i+1]-=minn;

//TODO

}

//TODO

}



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

if(a[i]>a[i+1]){

ok=1;

//TODO

}

//TODO

}



if(ok){

cout<<"NO"<<endl;

//TODO

}else{

cout<<"YES"<<endl;

}



}



return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

#define int long long

using namespace std;



int a[200005];



signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

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

cin>>a[i];

//TODO

}

int ok=0;

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

if(a[i+1]-a[i]<a[i+2]&&a[i]<=a[i+1]){

int minn=min(a[i],a[i+1]);

a[i]-=minn,a[i+1]-=minn;

//TODO

}

//TODO

}



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

if(a[i]>a[i+1]){

ok=1;

//TODO

}

//TODO

}



if(ok){

cout<<"NO"<<endl;

//TODO

}else{

cout<<"YES"<<endl;

}



}



return 0;

}

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

#define int long long

using namespace std;



int a[200005];



signed main(){

int t;

cin>>t;

while(t--){

int n;

cin>>n;

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

cin>>a[i];

//TODO

}

int ok=0;

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

if(a[i+1]-a[i]<=a[i+2]&&a[i]<=a[i+1]){

int minn=min(a[i],a[i+1]);

a[i]-=minn,a[i+1]-=minn;

//TODO

}

//TODO

}



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

if(a[i]>a[i+1]){

ok=1;

//TODO

}

//TODO

}



if(ok){

cout<<"NO"<<endl;

//TODO

}else{

cout<<"YES"<<endl;

}



}



return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 998244353;
#define fr(i, n) for (int i = 0; i < n; i++)
#define fr1(i, n) for (int i = 1; i < n; i++)
#define vi vector<int>
int hcf(int a, int g)
{
    if (g == 0)
        return a;
    else
        return hcf(g, a % g);
}
int lcm(int a, int g) { return (a * g) / hcf(a, g); }
int modInverse(int a, int mod) {
    int res = 1, p = mod - 2;
    while (p > 0) {
        if (p & 1) res = (res * a) % mod;
        a = (a * a) % mod;
        p >>= 1;
    }
    return res;
}
int N=1e6;
vi f(N+1,1),inv_f(N+1,1);
void precompute() {
    for (int i = 2; i <= N; ++i) {
        f[i] = (f[i - 1] * i) % mod;
    }
    inv_f[N] = modInverse(f[N], mod);
    for (int i = N - 1; i >= 1; --i) {
        inv_f[i] = (inv_f[i + 1] * (i + 1)) % mod;
    }
}
int ncr(int n, int r) {
    if (r > n) return 0;
    return (f[n] * inv_f[r] % mod) * inv_f[n - r] % mod;
}

void solve()
{
    int n,m;
    cin>>n>>m;
    vi a(n);
    vi b(m);
    fr(i,n) cin>>a[i];
    fr(i,m) cin>>b[i];
    map<int,int> ma,mb;
    fr(i,m){
        mb[b[i]]++;
    }
    fr(i,n){
        ma[a[i]]++;
    }
    sort(a.begin(),a.end());
    fr(i,n){
        if(ma[a[i]]>=mb[a[i]]){
            ma[a[i]]-=mb[a[i]];
            mb[a[i]]=0;
        }
    }
    int f=0,x=0;

    for(int i=0;i<n;i++){
        if(ma[a[i]]==0) continue;
        else{
            if(f==0){
                x=a[i];
                ma[x]--;
                f=1;
            }
            else if(a[i]-x<=1){
                if(mb[x+a[i]]>0){ 
                mb[x+a[i]]--;
                f=0;
                x=0;
                }
                else x=x+a[i];
                ma[a[i]]--;
            }
        
        }
    }
    if(x!=0){
        cout<<"NO"<<endl;
        return;
    }
    fr(i,m){
        if(mb[b[i]]==0 && ma[b[i]]==0) continue;
        else{
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
   

}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    int cEven , cOdd;
    if(n%2==0){
        cOdd = n/2;
        cEven = n/2;
    }
    else{
        cEven = (n/2) + 1;
        cOdd = n/2;
    }
    int sumOdd = 0 , sumEven = 0 ;
    for(int i = 0;i < n; i ++){
        if (i%2==0){
            sumEven+=arr[i];
        }
        else{
            sumOdd+=arr[i];
        }
    }

    if( sumEven%cEven!=0 || sumOdd%cOdd!=0||sumEven/cEven != sumOdd/cOdd ){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    
}

int main(){

    Code By Rikie

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

    return 0;
}

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

using namespace std;

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &x : a) cin >> x;
    
    long long ods = 0, evs = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1) ods += a[i];
        else evs += a[i];
    }
    int odc = n / 2, evc = n / 2;
    if (n & 1) evc++;

    if (ods % odc != 0 || evs % evc != 0 || ods / odc != evs / evc) {
        cout << "NO";
        return;
    }
    cout << "YES";
}

int main() {
    int TESTS; cin >> TESTS;
    while (TESTS --> 0) {
        solve();
        cout << '\n';
    }
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


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

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    if(n==3){
        if(arr[1]-arr[0]==arr[2]-arr[1]){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    else{
        if(abs(arr[0]-arr[n-1])>1){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
}

int main(){

    Code By Rikie

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

    return 0;
}