Help me in solving CFRTEST problem

My issue

“When run on each test case individually, your code appears to be correct. However, when run on the entire test file, it returns a WA. The most common reasons for this are that you do not have a newline after each test case, or you do not reinitialize some variables in each test case.” i got this error idk why

My code

#include <stdio.h>

int nb_repetitons(int x, int y[50], int num)
{
    int repetitions = 0;
    for (int i = 0; i < x; i++){
        if (y[i] == num){
            repetitions++;
        }
    }
    if (repetitions > 1){
        return 0;
    }
    return 1;
}

void solve(){
    int n, y[50], ret;
    
    ret = 0;
    scanf("%d", &n);
    for (int i = 0; i <= n; i++){
        scanf("%d", &y[i]);
    }
    for (int i = 0; i <= n; i++){
        if (nb_repetitons(n, y, y[i]) == 1){
            ret++;
        }
    }
    if (ret == 0){
        ret = ret + 1;
    }
    if (ret != 1){
        ret = ret - 1;
    }
    printf("%d\n", ret);
}

int main(void) {
	int t;
	scanf("%d", &t);
	while(t--){
	    solve();
	}
	return 0;
}


Learning course: Arrays, Strings & Sorting
Problem Link: Devu and friendship testing Practice Problem in - CodeChef

@inputname
the logic is u have to count the distinct numbers overall the array.
refer my c++ code for better understanding

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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int a[n];
	    set<int> s;
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	        s.insert(a[i]);
	    }
	    cout<<s.size()<<endl;
	}
	return 0;
}