Why runtime error in some test cases

My issue

My code

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int size = 2 * n;
        int a[size];
        for (int i = 0; i < size; i++)
        {
            cin >> a[i];
        }

        sort(a,a+size);
        string s = "YES";
        
        for (int i = 0; i < size; i++)
        {
            if(a[i]==a[i+1] && a[i+1]==a[i+2]){
                s="NO";
            }
        }
        cout<<s<<"\n";
        
    }
    return 0;
}

Problem Link: CNDY Problem - CodeChef

@mankiratsaini
if u r checking for i+2 the loop should run i<size-2.