Help me in solving CNDY problem

My issue

my test case 2 is showing wrong ,what can be the reason

My code

#include <stdio.h>

int main(void) {
    int t,n,s=0;
    scanf("%d",&t);
    
    
    for(int j=0;j<t;j++){
         scanf("%d",&n);
         int a[2*n];
         for(int i=0;i<2*n;i++){
           scanf("%d",&a[i]);
        }
        for(int k=0;k<2*n-1;k++){
            for(int m=1+k;m<2*n;m++){
                if(a[k]==a[m]){
                   s++; 
                }
            }
        }
        if(s<=1){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
        s=0;
    }
    
    
	return 0;
}


Problem Link: Candies Practice Coding Problem - CodeChef

@dibyajyotinewa
plzz refer following c code

#include <stdio.h>
#include<stdbool.h>
int main(void) 
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int a[2*n];
        int count;
        bool terminate=false;
        for(int i=0;i<2*n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=0;i<2*n;i++)
        {
            count=0;
            for(int j=0;j<2*n;j++)
            {
                if(terminate) break;
                if(a[i]==a[j])
                {
                    count++;
                    if(count==3)
                    {
                        terminate=true;
                        break;
                    }
                }
            }
            if(terminate) break;
        }
        output:
        if(count<3)
            printf("YES\n");
        else
            printf("NO\n");
    }
	return 0;
}