Counter 라이브러리 사용하자
앞서 풀었던 것처럼 set사용하면 안된다
from collections import Counter
n = int(input())
arr = list(map(int,input().split()))
m = int(input())
card_list = list(map(int, input().split()))
c = Counter(arr)
ans = []
for card in card_list:
ans.append(c.get(card)) if card in c else ans.append(0)
print(*ans)
from collections import Counter
_ = int(input())
arr = list(map(int,input().split()))
_ = int(input())
card_list = list(map(int, input().split()))
C = Counter(arr)
print(' '.join(f'{C[card]}' if card in arr else '0' for card in card_list))