ShaysXIA/CodeInsightBench huggingface dataset:
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;

#define int long long

inline void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> q;
    vector<int> b(m + 1);
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        q.push(x);
    }
    for (int i = 1; i <= m; i++) cin >> b[i];
    sort(b.begin() + 1, b.end());
    int p = 1;
    while (q.size()) {
        int x = q.top();
        q.pop();
      //   cout << "x=" << x << '\n';
        if (p > n) {
            cout << "NO\n";
            return;
        }
        if (x == b[p]) {
            p++;
        } else {
            if (q.empty()) {
                cout << "NO\n";
                return;
            } else {
                int y = q.top();
                q.pop();
               //  cout << "y=" << y << '\n';
                if (abs(x - y) <= 1) {
                    if (x + y == b[p]) {
                        p++;
                    } else {
                        q.push(x + y);
                    }
                } else {
                    cout << "NO\n";
                    return;
                }
            }
        }
      //   cout << p << '\n';
    }
    cout << "YES\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) solve();
}
/*
1
4 2
1 1 3 3
3 5
*/
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define int long long

inline void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> q;
    vector<int> b(m + 1);
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        q.push(x);
    }
    for (int i = 1; i <= m; i++) cin >> b[i];
    sort(b.begin() + 1, b.end());
    int p = 1;
    while (q.size()) {
        int x = q.top();
        q.pop();
        //   cout << "x=" << x << '\n';
        if (p > n) {
            cout << "NO\n";
            return;
        }
        if (x == b[p]) {
            p++;
        } else {
            if (q.empty()) {
                cout << "NO\n";
                return;
            } else {
                int y = q.top();
                q.pop();
                //  cout << "y=" << y << '\n';
                if (abs(x - y) <= 1) {
                    if (x + y == b[p]) {
                        p++;
                    } else {
                        q.push(x + y);
                    }
                } else {
                    cout << "NO\n";
                    return;
                }
            }
        }
        //   cout << p << '\n';
    }
    if (p > m)
        cout << "YES\n";
    else
        cout << "NO\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) solve();
}
/*
1
4 2
1 1 3 3
3 5
*/

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

#define int long long

inline void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q1, q2;
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        q1.push(x);
    }
    for (int i = 1, x; i <= m; i++) {
        cin >> x;
        q2.push(x);
    }
    int cnt = n - m;
    while (q1.size() && q2.size() && (cnt--)) {
        while (q1.size() && q2.size() && (q1.top() == q2.top()))
            q1.pop(), q2.pop();
        if (q1.empty() || q2.empty()) break;
        int x = q1.top(), y = q2.top();
        if (y < x) {
            cout << "NO\n";
            return;
        } else {
            q2.pop();
            q2.push(y / 2);
            q2.push((y + 1) / 2);
        }
      //   cout << q1.size() << ' ' << q2.size() << '\n';
    }
    while (q1.size() && q2.size() && (q1.top() == q2.top())) q1.pop(), q2.pop();
    if (q1.empty() && q2.empty())
        cout << "YES\n";
    else
        cout << "NO\n";
   //  while (q1.size()) {
   //      cout << q1.top() << ' ';
   //      q1.pop();
   //  }
   //  cout << '\n';
   //  while (q2.size()) {
   //      cout << q2.top() << ' ';
   //      q2.pop();
   //  }
   //  cout << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) solve();
}
/*
1
18 8
1 2 10 3 3 2 3 3 2 1 1 1 5 2 1 1 2 2
7 9 1 6 5 2 10 5
*/
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 t;
    cin >> t;
    while(t--){
        long long int n;
        cin >> n;
        long long int arr[n], s=0;
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        if(n==1){
            s=arr[0];
        }else if(n==2){
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }else{
            for(int i=2; i<n; i++){
                for(int i=1; i<n; i++){
                    arr[i-1] -= arr[i];
                }
            }
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }
        cout << s << endl;
    }
}
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 t;
    cin >> t;
    while(t--){
        long long int n;
        cin >> n;
        long long int arr[n], s=0;
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        if(n==1){
            s=arr[0];
        }else if(n==2){
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }else{
            for(int i=2; i<n; i++){
                for(int j=1; j<n; j++){
                    arr[j-1] -= arr[j];
                }
            }
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }
        cout << s << endl;
    }
}

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

int main(){
    int t;
    cin >> t;
    while(t--){
        long long int n;
        cin >> n;
        long long int arr[n], s=0, k=0;
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        if(n==1){
            s=arr[0];
        }else if(n==2){
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }else{
            for(int i=2; i<n; i++){
                for(int j=1; j<n; j++){
                    arr[j-1] -= arr[j];
                }
                k += arr[i];
            }
            k += arr[0]+arr[1];
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
            s = max(s, k);
        }
        cout << s << endl;
    }
}
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 t;
    cin >> t;
    while(t--){
        long long int n;
        cin >> n;
        long long int arr[n], s=0;
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        if(n==1){
            s=arr[0];
        }else if(n==2){
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }else{
            for(int i=2; i<n; i++){
                for(int i=1; i<n; i++){
                    arr[i-1] -= arr[i];
                }
            }
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }
        cout << s << endl;
    }
}

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

int main(){
    int t;
    cin >> t;
    while(t--){
        long long int n;
        cin >> n;
        long long int arr[n], s=0;
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        if(n==1){
            s=arr[0];
        }else if(n==2){
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }else{
            for(int i=2; i<n; i++){
                for(int j=1; j<(n-i+2); j++){
                    arr[j-1] -= arr[j];
                }
            }
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }
        cout << s << endl;
    }
}
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 t;
    cin >> t;
    while(t--){
        long long int n;
        cin >> n;
        long long int arr[n], s=0, k=0;
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        if(n==1){
            s=arr[0];
        }else if(n==2){
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }else{
            for(int i=2; i<n; i++){
                for(int j=1; j<n; j++){
                    arr[j-1] -= arr[j];
                }
                k += arr[i];
            }
            k += arr[0]+arr[1];
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
            s = max(s, k);
        }
        cout << s << endl;
    }
}

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

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        long long int s=0, m=0;
        long long int arr[n];
        for(int i=0; i<n; i++){
            cin >> arr[i];
            m += arr[i];
        }
        for(int i=0; i<(n-1); i++){
            s=0;
            for(int j=0; j<(n-1-i); j++){
                arr[j] -= arr[j+1];
                s += arr[j];
            }
            m = max(m, s);
            m = max(m, -s);
        }
        cout << m << endl;
    }
}
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 t;
    cin >> t;
    while(t--){
        long long int n;
        cin >> n;
        long long int arr[n], s=0;
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        if(n==1){
            s=arr[0];
        }else if(n==2){
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }else{
            for(int i=2; i<n; i++){
                for(int j=1; j<(n-i+2); j++){
                    arr[j-1] -= arr[j];
                }
            }
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }
        cout << s << endl;
    }
}

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

int main(){
    int t;
    cin >> t;
    while(t--){
        long long int n;
        cin >> n;
        long long int arr[n], s=0;
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        if(n==1){
            s=arr[0];
        }else if(n==2){
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }else{
            for(int i=2; i<n; i++){
                for(int j=1; j<n; j++){
                    arr[j-1] -= arr[j];
                }
            }
            if(arr[0]>0 && arr[1]>0){
                s = arr[0]+arr[1];
            }else{
                if(arr[0]>arr[1]){
                    s = arr[0]-arr[1];
                }else{
                    s = arr[1]-arr[0];
                }
            }
        }
        cout << s << endl;
    }
}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


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

#ifdef LOCAL16

#include "debug.h"

#else

#define debug(...)

#endif



#define endln '\n'

#define print(x) cout << (x) << endln



using namespace std;

using ll = long long;

const int INF = INT_MAX - 1;

const ll LINF = LLONG_MAX - 1;



const int maxN = 2e5 + 5;

int arr[maxN];

int n;



void solve()

{

    int x, y;

    cin >> n;

    cin >> x >> y;

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

    {

        arr[i] = (i + 1) % 2;

    }

    int changes = 0;

    if (arr[n] == 0)

    {

        arr[n] = 2;

        changes++;

    }

    if (arr[x] == arr[y])

    {

        arr[y] = 2;

        changes++;

    }

    if (changes < 2)

    {

    }

    else

    {

        changes = 0;

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

        {

            arr[i] = (i) % 2;

        }

        if (arr[0] == arr[n])

        {

            arr[n] = 2;

            changes++;

        }

        if (arr[x] == arr[y])

        {

            arr[y] = 2;

            changes++;

        }

    }

    assert(changes < 2);

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

    {

        cout << arr[i] << " ";

    }

    cout << endln;

}



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

}



/*

I have lost all confidence in you

*/
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

#ifdef LOCAL16

#include "debug.h"

#else

#define debug(...)

#endif



#define endln '\n'

#define print(x) cout << (x) << endln



using namespace std;

using ll = long long;

const int INF = INT_MAX - 1;

const ll LINF = LLONG_MAX - 1;



const int maxN = 2e5 + 5;

int arr[maxN];

int n;



void solve()

{

    int x, y;

    cin >> n;

    cin >> x >> y;

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

    {

        arr[i] = (i + 1) % 2;

    }

    int changes = 0;

    if (arr[n] == 0)

    {

        arr[n] = 2;

        changes++;

    }

    if (arr[x] == arr[y])

    {

        arr[y] = 2;

        changes++;

    }

    if (changes < 2)

    {

    }

    else

    {

        changes = 0;

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

        {

            arr[i] = (i) % 2;

        }

        if (arr[0] == arr[n])

        {

            arr[n] = 2;

            changes++;

        }

        if (arr[x] == arr[y])

        {

            arr[y] = 2;

            changes++;

        }

    }

    assert(changes < 2);

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

    {

        cout << arr[i] << " ";

    }

    cout << endln;

}



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

}



/*

I have lost all confidence in you

*/

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

#ifdef LOCAL16

#include "debug.h"

#else

#define debug(...)

#endif



#define endln '\n'

#define print(x) cout << (x) << endln



using namespace std;

using ll = long long;

const int INF = INT_MAX - 1;

const ll LINF = LLONG_MAX - 1;



const int maxN = 2e5 + 5;

int arr[maxN];

int n;



void solve()

{

    int x, y;

    cin >> n;

    cin >> x >> y;

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

    {

        arr[i] = (i + 1) % 2;

    }

    int changes = 0;

    if (arr[n] == 0)

    {

        arr[n] = 2;

        changes++;

    }

    if (arr[x] == arr[y])

    {

        arr[y] = 2;

        changes++;

    }

    if (changes < 2)

    {

    }

    else

    {

        changes = 0;

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

        {

            arr[i] = (i) % 2;

        }

        if (arr[1] == arr[n])

        {

            arr[1] = 2;

            changes++;

        }

        if (arr[x] == arr[y])

        {

            arr[y] = 2;

            changes++;

        }

    }

    assert(changes < 2);

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

    {

        cout << arr[i] << " ";

    }

    cout << endln;

}



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

}



/*

I have lost all confidence in you

*/
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

#ifdef LOCAL16

#include "debug.h"

#else

#define debug(...)

#endif



#define endln '\n'

#define print(x) cout << (x) << endln



using namespace std;

using ll = long long;

const int INF = INT_MAX - 1;

const ll LINF = LLONG_MAX - 1;



const int maxN = 2e5 + 5;

int arr[maxN];

int n;



void solve()

{

    int x, y;

    cin >> n;

    cin >> x >> y;

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

    {

        arr[i] = (i + 1) % 2;

    }

    int changes = 0;

    if (arr[n] == 0)

    {

        arr[n] = 2;

        changes++;

    }

    if (arr[x] == arr[y])

    {

        arr[y] = 2;

        changes++;

    }

    if (changes < 2)

    {

    }

    else

    {

        changes = 0;

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

        {

            arr[i] = (i) % 2;

        }

        if (arr[1] == arr[n])

        {

            arr[1] = 2;

            changes++;

        }

        if (arr[x] == arr[y])

        {

            arr[y] = 2;

            changes++;

        }

    }

    assert(changes < 2);

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

    {

        cout << arr[i] << " ";

    }

    cout << endln;

}



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

}



/*

I have lost all confidence in you

*/

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

#ifdef LOCAL16

#include "debug.h"

#else

#define debug(...)

#endif



#define endln '\n'

#define print(x) cout << (x) << endln



using namespace std;

using ll = long long;

const int INF = INT_MAX - 1;

const ll LINF = LLONG_MAX - 1;



const int maxN = 2e5 + 5;

int arr[maxN];

int n;

int x, y;



bool start(int index)

{

    int cur = index;

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

    {

        arr[cur] = i % 2;

        cur++;

        if (cur > n)

        {

            cur = 1;

        }

    }

    int last = cur - 1;

    if (last <= 0)

    {

        last = n;

    }

    int changes = 0;

    if (arr[last] == arr[index])

    {

        arr[last] = 2;

        changes++;

    }

    if (arr[x] == arr[y])

    {

        arr[y] = 2;

        changes++;

    }

    return changes < 2;

}

void solve()

{

    cin >> n;

    cin >> x >> y;

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

    {

        arr[i] = (i + 1) % 2;

    }

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

    {

        if (start(i))

        {

            for (int j = 1; j <= n; j++)

            {

                cout << arr[j] << " ";

            }

            cout << endln;

            return;

        }

    }

    assert(false);

}



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

}



/*

I have lost all confidence in you

*/
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100010;

int t , n;
int a[N];


int main()
{
    cin >> t;

    while( t -- )
    {
        cin >> n;

        int ans = 0;
        for(int i = 0 ; i < n ; i ++ ) {cin >> a[i];ans += a[i];}

        
        while( n > 1)
        {   
            int sum = 0;
            for(int i = 0;i < n - 1 ; i ++) 
            {
                a[i] = a[i + 1] - a[i];
                sum += a[i];
            }

            ans = max(ans, abs(sum));

            n --;
        }
        
        cout << ans << endl ;
        
    }

    return 0 ;
}

Submission (verdict: Wrong answer on test 2):
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int N = 100010;

int t , n;
int a[N];


int main()
{
    cin >> t;

    while( t -- )
    {
        cin >> n;

        LL ans = 0;
        for(int i = 0 ; i < n ; i ++ ) {cin >> a[i];ans += a[i];}

        
        while( n > 1)
        {   
            LL sum = 0;
            for(int i = 0;i < n - 1 ; i ++) 
            {
                a[i] = a[i + 1] - a[i];
                sum += a[i];
            }

            ans = max(ans, abs(sum));

            n --;
        }
        
        cout << ans << endl ;
        
    }

    return 0 ;
}