ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> final(n);
    for(auto& val : final)  
        cin >> val;
    vector<int> initial;
    vector<vector<bool>> taken(n+1, vector<bool>(n+1, false));
    for(int i=1;i<=n;i++)
        initial.push_back(i);
    int ans = 0;
    vector<pair<int,int>> order;
    for(int i=0;i<n;i++) {
        int j = i;
        for(;j<n;j++) {
            if(initial[j] == final[i]) {
                break;
            }
        }
        for(int k=j-1;k>=i;k--) {
            swap(initial[k], initial[k+1]);
            order.push_back({initial[k], initial[k+1]});
            taken[initial[k]][initial[k+1]] = true;
            ++ans;
        }
    }
    for(int i=0;i<n;i++) {
        int j = i+1;
        for(;j<n;j++) {
            int num1 = initial[j-1];
            int num2 = initial[j];
            if(taken[num1][num2] == false && taken[num2][num1] == false) {
                ++ans;
                order.push_back({num2, num1});
            } else {
                break;
            }
        }
        j--;
        for(;j>i;j--) {
            int num1 = initial[j];
            int num2 = initial[j-1];
            ++ans;
            order.push_back({num2, num1});
        }
    }
    cout << ans << "\n";
    for(auto& val : order) 
        cout << val.first << " " << val.second << "\n";
    return 0;
}

Submission (verdict: Wrong answer on test 7):
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int> final(n);
    for(auto& val : final)  
        cin >> val;
    vector<int> initial;
    vector<vector<bool>> taken(n+1, vector<bool>(n+1, false));
    for(int i=1;i<=n;i++)
        initial.push_back(i);
    int ans = 0;
    vector<pair<int,int>> order;
    for(int i=0;i<n;i++) {
        int j = i;
        for(;j<n;j++) {
            if(initial[j] == final[i]) {
                break;
            }
        }
        for(int k=j-1;k>=i;k--) {
            swap(initial[k], initial[k+1]);
            order.push_back({initial[k], initial[k+1]});
            taken[initial[k]][initial[k+1]] = true;
            ++ans;
        }
    }
    for(int i=0;i<n;i++) {
        int j = i+1;
        for(;j<n;j++) {
            int& num1 = initial[j-1];
            int& num2 = initial[j];
            if(taken[num1][num2] == false && taken[num2][num1] == false) {
                ++ans;
                swap(num1, num2);
                order.push_back({num1, num2});
            } else {
                break;
            }
        }
        j--;
        for(;j>i;j--) {
            int& num1 = initial[j];
            int& num2 = initial[j-1];
            swap(num1, num2);
            ++ans;
            order.push_back({num2, num1});
        }
    }
    cout << ans << "\n";
    for(auto& val : order) 
        cout << val.first << " " << val.second << "\n";
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		if (n == 1)
		{
			cout << "1" << "\n";
			continue;
		}
		long long a[n+10],b[n+10];
		for (int i = 1; i <= n; i++)cin >> a[i];
		sort(&a[1], &a[1] + n);
		int ans = 1;
		int m = 0;
		for (int i = 1; i < n; i++)
		{
			m++;
			if (a[i] != a[i + 1])
			{
				b[ans] = m;
				ans++;
				m = 0;
			}
		}
		if (a[n - 1] == a[n])b[ans] = m;
		else b[ans] = 1;
		sort(&b[1], &b[1] + ans);
		int p = 0;
		for (int i = 1; i <= ans; i++)
		{
			if (k - b[i] >= 0)
			{
				p++;
				k = k - b[i];
			}
			else
			{
				k = 0;
				break;
			}
		}
		k = k + p;
		if (k >= ans - 1)ans = 1;
		else ans = ans - k;
		cout << ans << "\n";
	}
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		long long a[n+10],b[n+10];
		for (int i = 1; i <= n; i++)cin >> a[i];
		if (n == 1)
		{
			cout << "1" << "\n";
			continue;
		}
		sort(&a[1], &a[1] + n);
		int ans = 1;
		int m = 0;
		for (int i = 1; i < n; i++)
		{
			m++;
			if (a[i] != a[i + 1])
			{
				b[ans] = m;
				ans++;
				m = 0;
			}
		}
		if (a[n - 1] == a[n])b[ans] = m;
		else b[ans] = 1;
		sort(&b[1], &b[1] + ans);
		int p = 0;
		for (int i = 1; i <= ans; i++)
		{
			if (k - b[i] >= 0)
			{
				p++;
				k = k - b[i];
			}
			else
			{
				k = 0;
				break;
			}
		}
		k = k + p;
		if (k >= ans - 1)ans = 1;
		else ans = ans - k;
		cout << ans << "\n";
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		long long a[n+10],b[n+10];
		for (int i = 1; i <= n; i++)cin >> a[i];
		sort(&a[1], &a[1] + n);
		int ans = 1;
		int m = 0;
		for (int i = 1; i < n; i++)
		{
			m++;
			if (a[i] != a[i + 1])
			{
				b[ans] = m;
				ans++;
				if(i!=n-1)m = 0;
			}
		}
		b[ans] = m;
		sort(&b[1], &b[1] + ans);
		int p = 0;
		for (int i = 1; i <= ans; i++)
		{
			if (k - b[i] >= 0)
			{
				p++;
				k = k - b[i];
			}
			else
			{
				k = 0;
				break;
			}
		}
		k = k + p;
		if (k >= ans - 1)ans = 1;
		else ans = ans - k;
		cout << ans << "\n";
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		long long a[n+10],b[n+10];
		for (int i = 1; i <= n; i++)cin >> a[i];
		sort(&a[1], &a[1] + n);
		int ans = 1;
		int m = 0;
		for (int i = 1; i < n; i++)
		{
			m++;
			if (a[i] != a[i + 1])
			{
				b[ans] = m;
				ans++;
				if(i!=n-1)m = 0;
			}
		}
		b[ans] = m;
		sort(&b[1], &b[1] + ans);
		int p = 0;
		for (int i = 1; i <= ans; i++)
		{
			if (k - b[i] >= 0)
			{
				p++;
				k = k - b[i];
			}
			else
			{
				k = 0;
				break;
			}
		}
		k = k + p;
		if (k >= ans - 1)ans = 1;
		else ans = ans - k;
		cout << ans << "\n";
	}
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		if (n == 1)
		{
			cout << "1" << "\n";
			continue;
		}
		long long a[n+10],b[n+10];
		for (int i = 1; i <= n; i++)cin >> a[i];
		sort(&a[1], &a[1] + n);
		int ans = 1;
		int m = 0;
		for (int i = 1; i < n; i++)
		{
			m++;
			if (a[i] != a[i + 1])
			{
				b[ans] = m;
				ans++;
				m = 0;
			}
		}
		if (a[n - 1] == a[n])b[ans] = m;
		else b[ans] = 1;
		sort(&b[1], &b[1] + ans);
		int p = 0;
		for (int i = 1; i <= ans; i++)
		{
			if (k - b[i] >= 0)
			{
				p++;
				k = k - b[i];
			}
			else
			{
				k = 0;
				break;
			}
		}
		k = k + p;
		if (k >= ans - 1)ans = 1;
		else ans = ans - k;
		cout << ans << "\n";
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		long long a[n+10],b[n+10];
		for (int i = 1; i <= n; i++)cin >> a[i];
		if (n == 1)
		{
			cout << "1" << "\n";
			continue;
		}
		sort(&a[1], &a[1] + n);
		int ans = 1;
		int m = 0;
		for (int i = 1; i < n; i++)
		{
			m++;
			if (a[i] != a[i + 1])
			{
				b[ans] = m;
				ans++;
				m = 0;
			}
		}
		if (a[n - 1] == a[n])b[ans] = m;
		else b[ans] = 1;
		sort(&b[1], &b[1] + ans);
		int p = 0;
		for (int i = 1; i <= ans; i++)
		{
			if (k - b[i] >= 0)
			{
				p++;
				k = k - b[i];
			}
			else
			{
				k = 0;
				break;
			}
		}
		k = k + p;
		if (k >= ans - 1)ans = 1;
		else ans = ans - k;
		cout << ans << "\n";
	}
}

Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		long long a[n+10],b[n+10];
		for (int i = 1; i <= n; i++)cin >> a[i];
		if (n == 1)
		{
			cout << "1" << "\n";
			continue;
		}
		sort(&a[1], &a[1] + n);
		int ans = 1;
		int m = 0;
		for (int i = 1; i < n; i++)
		{
			m++;
			if (a[i] != a[i + 1])
			{
				b[ans] = m;
				ans++;
				m = 0;
			}
		}
		if (a[n - 1] == a[n])b[ans] = m+1;
		else b[ans] = 1;
		sort(&b[1], &b[1] + ans);
		int p = 0;
		for (int i = 1; i <= ans; i++)
		{
			if (k - b[i] >= 0)
			{
				p++;
				k = k - b[i];
			}
			else
			{
				k = 0;
				break;
			}
		}
		k = k + p;
		if (k >= ans - 1)ans = 1;
		else ans = ans - k;
		cout << ans << "\n";
	}
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

using namespace std;

typedef long long ll;

int main()

{

    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int T;

    cin>>T;

    while(T--)

    {

        int n,m;

        cin>>n>>m;

        multiset<ll> mset,need;

        vector<ll> a(n+1),b(m+1);

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

        {

        	cin>>a[i];

        	mset.insert(a[i]);

		}

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

		{

			cin>>b[i];

			if(mset.find(b[i])!=mset.end())

			{

				mset.erase(mset.find(b[i]));

			}

			else

			{

				need.insert(b[i]);

			}

		}

		int ok=1;

		ll muqian=0;

		for(auto num:mset)

		{

			if(muqian==0) muqian=num;

			else if(abs(muqian-num)<=1)

			{

				muqian+=num;

				if(need.find(muqian)!=need.end())

				{

					need.erase(need.find(muqian));

					muqian=0;

				}

			}

			else

			{

				ok=0;

				break;

			}

		}

		if(muqian||(!need.empty())) ok=0;

		if(ok) cout<<"YES"<<endl;

		else cout<<"NO"<<endl;

	}

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

int main()

{

    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int T;

    cin>>T;

    while(T--)

    {

        int n,m;

        cin>>n>>m;

        multiset<ll> mset,need;

        vector<ll> a(n+1),b(m+1);

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

        {

        	cin>>a[i];

        	mset.insert(a[i]);

		}

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

		{

			cin>>b[i];

			if(mset.find(b[i])!=mset.end())

			{

				mset.erase(mset.find(b[i]));

			}

			else

			{

				need.insert(b[i]);

			}

		}

		int ok=1;

		while(mset.size()>=2)

		{

			auto k1=mset.begin(),k2=next(k1);

			ll v1=*k1,v2=*k2;

			mset.erase(k1),mset.erase(k2);

			

			if(abs(v1-v2)<=1)

			{

				ll v3=v1+v2;

				if(need.find(v3)!=need.end())

				{

					need.erase(need.find(v3));

				}

				else

				{

					mset.insert(v3);

				}

			}

			else

			{

				ok=0;

				break;

			}

		}

		if((!mset.empty())||(!need.empty())) ok=0;

		if(ok) cout<<"YES"<<endl;

		else cout<<"NO"<<endl;

	}

    return 0;

}

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

using namespace std;

typedef long long ll;

multiset<ll> mset;

vector<ll> need;

bool search(ll x)

{

	if(x==0) return false;

	ll n1=x/2,n2=n1;

	if(x%2==1) n2++;

	if(mset.find(n1)!=mset.end()) mset.erase(mset.find(n1));

	else if(search(n1));

	else return false;

	

	if(mset.find(n2)!=mset.end()) mset.erase(mset.find(n2));

	else if(search(n2));

	else return false;

	

	return true;

}

int main()

{

    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int T;

    cin>>T;

    while(T--)

    {

        int n,m;

        cin>>n>>m;

       	mset.clear(),need.clear();

        vector<ll> a(n+1),b(m+1);

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

        {

        	cin>>a[i];

        	mset.insert(a[i]);

		}

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

		{

			cin>>b[i];

			if(mset.find(b[i])!=mset.end())

			{

				mset.erase(mset.find(b[i]));

			}

			else

			{

				need.push_back(b[i]);

			}

		}

		int ok=1,key=-1;

		for(int i=0;i<need.size();i++)

		{

			key=i;

			if(!search(need[i])) 

			{

				ok=0;

				break;

			}

		}

		if((!mset.empty())||(key!=need.size()-1)) ok=0;

		if(ok) cout<<"YES"<<endl;

		else cout<<"NO"<<endl;

	}

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

int main()

{

    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int T;

    cin>>T;

    while(T--)

    {

        int n,m;

        cin>>n>>m;

        multiset<ll> mset,need;

        vector<ll> a(n+1),b(m+1);

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

        {

        	cin>>a[i];

        	mset.insert(a[i]);

		}

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

		{

			cin>>b[i];

			if(mset.find(b[i])!=mset.end())

			{

				mset.erase(mset.find(b[i]));

			}

			else

			{

				need.insert(b[i]);

			}

		}

		int ok=1;

		ll muqian=0;

		for(auto num:mset)

		{

			if(muqian==0) muqian=num;

			else if(abs(muqian-num)<=1)

			{

				muqian+=num;

				if(need.find(muqian)!=need.end())

				{

					need.erase(need.find(muqian));

					muqian=0;

				}

			}

			else

			{

				ok=0;

				break;

			}

		}

		if(muqian||(!need.empty())) ok=0;

		if(ok) cout<<"YES"<<endl;

		else cout<<"NO"<<endl;

	}

    return 0;

}

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

using namespace std;

typedef long long ll;

int main()

{

    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int T;

    cin>>T;

    while(T--)

    {

        int n,m;

        cin>>n>>m;

        multiset<ll> mset,need;

        vector<ll> a(n+1),b(m+1);

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

        {

        	cin>>a[i];

        	mset.insert(a[i]);

		}

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

		{

			cin>>b[i];

			if(mset.find(b[i])!=mset.end())

			{

				mset.erase(mset.find(b[i]));

			}

			else

			{

				need.insert(b[i]);

			}

		}

		int ok=1;

		while(mset.size()>=2)

		{

			auto k1=mset.begin(),k2=next(k1);

			ll v1=*k1,v2=*k2;

			mset.erase(k1),mset.erase(k2);

			

			if(abs(v1-v2)<=1)

			{

				ll v3=v1+v2;

				if(need.find(v3)!=need.end())

				{

					need.erase(need.find(v3));

				}

				else

				{

					mset.insert(v3);

				}

			}

			else

			{

				ok=0;

				break;

			}

		}

		if((!mset.empty())||(!need.empty())) ok=0;

		if(ok) cout<<"YES"<<endl;

		else cout<<"NO"<<endl;

	}

    return 0;

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


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int t;
    cin >> t;
    
    while(t--) {
        int n;
        cin >> n;
        vector<int> arr(n + 1);
        
        for(int i = 1; i <= n; i++) {
            cin >> arr[i];
        }
        
        int row = n;
        long long sum = LLONG_MIN;
        
        for(int j = 1; j <= n; j++) {
            long long ans = 0;
            for(int b = 1; b <= row; b++) {
                ans += arr[b];
            }
            
            if(j == 1) {
                sum = max(ans, sum);
            } else {
                sum = max(sum, max(-ans, ans));
            }
            
            for(int a = 1; a < row; a++) {
                arr[a] = arr[a + 1] - arr[a];
            }
            row--;
        }
        
        cout << sum << 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 <vector>
#include <algorithm>
using namespace std;

int main() {
    int t;
    cin >> t;
    
    while(t--) {
        int n;
        cin >> n;
        vector<int> arr(n + 1);
        
        for(int i = 1; i <= n; i++) {
            cin >> arr[i];
        }
        
        int row = n;
        long long sum = -1e18;
        
        for(int j = 1; j <= n; j++) {
            long long ans = 0;
            for(int b = 1; b <= row; b++) {
                ans += arr[b];
            }
            
            if(j == 1) {
                sum = max(ans, sum);
            } else {
                sum = max(sum, max(-ans, ans));
            }
            
            for(int a = 1; a < row; a++) {
                arr[a] = arr[a + 1] - arr[a];
            }
            row--;
        }
        
        cout << sum << endl;
    }

    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int t;
    cin >> t;
    
    while(t--) {
        int n;
        cin >> n;
        vector<long long> arr(n + 1);
        
        for(int i = 1; i <= n; i++) {
            cin >> arr[i];
        }
        
        int row = n;
        long long sum = -1e18;
        
        for(int j = 1; j <= n; j++) {
            long long ans = 0;
            for(int b = 1; b <= row; b++) {
                ans += arr[b];
            }
            
            if(j == 1) {
                sum = max(ans, sum);
            } else {
                sum = max(sum, max(-ans, ans));
            }
            
            for(int a = 1; a < row; a++) {
                arr[a] = arr[a + 1] - arr[a];
            }
            row--;
        }
        
        cout << sum << 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 <vector>
#include <algorithm>
using namespace std;

int main() {
    int t;
    cin >> t;
    
    while(t--) {
        int n;
        cin >> n;
        vector<int> arr(n + 1);
        
        for(int i = 1; i <= n; i++) {
            cin >> arr[i];
        }
        
        int row = n;
        long long sum = LLONG_MIN;
        
        for(int j = 1; j <= n; j++) {
            long long ans = 0;
            for(int b = 1; b <= row; b++) {
                ans += arr[b];
            }
            
            if(j == 1) {
                sum = max(ans, sum);
            } else {
                sum = max(sum, max(-ans, ans));
            }
            
            for(int a = 1; a < row; a++) {
                arr[a] = arr[a + 1] - arr[a];
            }
            row--;
        }
        
        cout << sum << endl;
    }

    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int t;
    cin >> t;
    
    while(t--) {
        int n;
        cin >> n;
        vector<int> arr(n + 1);
        
        for(int i = 1; i <= n; i++) {
            cin >> arr[i];
        }
        
        int row = n;
        long long sum = -1e18;
        
        for(int j = 1; j <= n; j++) {
            long long ans = 0;
            for(int b = 1; b <= row; b++) {
                ans += arr[b];
            }
            
            if(j == 1) {
                sum = max(ans, sum);
            } else {
                sum = max(sum, max(-ans, ans));
            }
            
            for(int a = 1; a < row; a++) {
                arr[a] = arr[a + 1] - arr[a];
            }
            row--;
        }
        
        cout << sum << endl;
    }

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define  nl "\n"
#define forn(a, c) for (int a = 0; a < c; a++) 
#define forl(a, b, c) for (int a = b; a <= c; a++) 
#define forr(a, b, c) for (int a = b; a >= c; a--)
#define cin(v) for(auto &i:v){cin>>i;}
#define cout(v) for(auto &i:v){cout<<i<<" ";}cout<<nl;
#define all(a) a.begin(),a.end()
#define fast() (ios_base::sync_with_stdio(false), cin.tie(NULL));
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
    int n;cin>>n;
    // std::vector<pair<int,int>> v(n);
    map<int,int> edge;
    map<int,int> mp;
    int mx = 0;
    int e1 = 0;
    forn(i,n-1){
        int x,y;cin>>x>>y;
        edge[x] = y;
        mp[x]++;
        mp[y]++;
        if( mx < mp[x]){mx = mp[x];e1 = x;}
        if(mx < mp[y]){mx = mp[y];e1 = y;}
    }
    // for(auto &i:edge){
    //     cout<<i.first<<' '<<i.second<<nl;
    // }
    int mx2 = 0;
    int e2 = 0;
    for(auto &i:mp){
        if(mx-mx2 > mx-i.second && e1 != i.first){mx2 = i.second;e2 = i.first;}
    }
    // cout<<mx<<" "<<mx2<<nl;
    // cout<<e2<<nl;
    int c = mx2 + mx -1;
    if(edge[e1] == e2 || edge[e2] == e1)c--;
    cout<<c<<nl;
}

signed main()
{
    auto begin = std::chrono::high_resolution_clock::now();
    fast();
    int tt;cin>>tt;
    while(tt--){
        solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;



void solve(){

    int n; cin >> n;

    vector<int> ar(n);

    for (int i=0; i<n; i++) cin >> ar[i];

    int prev = -1;



    bool invalid = false;

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

        if (prev > ar[i] and ar[i] > ar[i+1]){

            invalid = true;

            break;

        }

        prev = ar[i];

    }



    prev = 0;

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

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

            ar[i] -= min(ar[i], prev);

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

                invalid = true;

                break;

            }

        }

        prev = ar[i];

    }

    cout << (invalid ? "NO" : "YES") << endl;

}



int main(){

    int t; cin >> t;

    while (t--){

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;



void solve(){

    int n; cin >> n;

    vector<int> ar(n);

    for (int i=0; i<n; i++) cin >> ar[i];

    int prev = -1;



    bool invalid = false;

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

        if (prev > ar[i] and ar[i] > ar[i+1]){

            invalid = true;

            break;

        }

        prev = ar[i];

    }



    prev = 0;

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

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

            ar[i] -= min(ar[i], prev);

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

                invalid = true;

                break;

            }

        }

        prev = ar[i];

    }

    cout << (invalid ? "NO" : "YES") << endl;

}



int main(){

    int t; cin >> t;

    while (t--){

        solve();

    }

    return 0;

}

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

using namespace std;



void solve(){

    int n; cin >> n;

    vector<int> ar(n);

    for (int i=0; i<n; i++) cin >> ar[i];

    int prev = -1;



    bool invalid = false;

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

        if (prev > ar[i] and ar[i] > ar[i+1]){

            invalid = true;

            break;

        }

        prev = ar[i];

    }



    prev = 0;

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

        if (ar[i] >= ar[i+1]){

            ar[i] -= min(ar[i], prev);

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

                invalid = true;

                break;

            }

        }

        prev = ar[i];

    }

    cout << (invalid ? "NO" : "YES") << endl;

}



int main(){

    int t; cin >> t;

    while (t--){

        solve();

    }

    return 0;

}