#include <stdio.h>
int main() {
int n, pares = 0;
scanf("%d", &n);
int b[n];
char p[n];
for(int i=0; i<n; i++){
scanf("%d", &b[i]);
scanf(" %c", &p[i]);
}
for(int i=0; i<n; i++){
for(int j = i+1; j<n; j++){
if(b[j]!= -1 && b[i]==b[j] && p[i]!=p[j]){
pares++;
b[i] = -1;
b[j] = -1;
break;
}
}
}
printf("%d", pares);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: