It gives error after submit but works fine on sample input? https://www.codechef.com/problems/AIRM

include
using namespace std;

int main() {
int T;
cin >> T;
while(T>0){
int n;
cin >> n;
int arriv[n];
int depar[n];
for(int i=0;i<n;i++){
cin >> arriv[i];
}
for(int i=0;i<n;i++){
cin >> depar[i];
}
int runaw = 1;
for(int i=0;i<n;i++){
if(arriv[i] == 0 || depar[i] == 0){
continue;
}
for(int j= i+1;j<n;j++){
if(arriv[i] == arriv[j] || arriv[i] == depar[j] || depar[i] == arriv[j]
|| depar[i] == depar[j] ){
runaw++;
arriv[j] = 0;
depar[j] = 0;
}
}
}
cout << runaw << endl;
T–;
}
return 0;
}

@ankush86
The logic is to count the maximum freq and then print it both including arrival and departure .
like
1 1 2
2 2 3
the freq of 1 is 1
the freq of 2 is 3
the freq of 3 is 1
so the maximum freq we get is 3 so our answer will be 3.