Help me in solving CARDSWIPE problem

My issue

it shows time limit exceeded…

My code

#include<stdio.h>

int main() {
    int T, N;
    int C = 0, M = 0, count = 0;
    scanf("%d", &T);
    
    for(int i=0; i<T; i++) {
        scanf("%d", &N);
        int arr[N];
        
        for(int j=0; j<N; j++) {
            scanf("%d", &arr[j]);
        }
        
        for(int i=0; i<N; i++) {
            for(int j=0; j<i; j++) {
                if(arr[i] == arr[j]) {
                    count++;
                    }
            }
            if(count == 0) {
                C++;
            } else if(count%2 != 0) {
                C--;
            } else {
                C++;
            }
            if(C>M) {
                M=C;
            }
            count = 0;
        }
        
        printf("%d\n", M);
        M = C = 0;
    }
    
    return 0;
}

Problem Link: CARDSWIPE Problem - CodeChef