Count Specific Elements
Given a list of N integers, and a list of K special integers, count how many times each special integer appears in the given list. Print the counts for each special integer in the order they appear in the special integers list.
Input
The first line contains two integers N and K, separated by a space. The second line contains N integers, the list of numbers. The third line contains K integers, the list of special numbers.
Output
Print K integers, where the i-th integer is the count of the i-th special number in the list of N integers. The counts should be separated by spaces.
Constraints
1 <= N <= 1000 1 <= K <= 1000 Each integer in the lists will be between -1000 and 1000.
Example 1
5 3 1 2 3 2 1 1 2 4
2 2 0
The number 1 appears 2 times, 2 appears 2 times, and 4 appears 0 times.
Example 2
7 4 10 10 20 30 10 20 10 10 20 30 40
4 2 1 0
10 appears 4 times, 20 appears 2 times, 30 appears 1 time, and 40 appears 0 times.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
5 3 1 2 3 2 1 1 2 4
7 4 10 10 20 30 10 20 10 10 20 30 40