• + 1 comment

    2 lines in python does the work.

    s=[input() for s in range(int(input()))]
    [print(s.count(input())) for j in range(int(input()))]
    

    first line stores the inputs in a list. second line counts the occurances of present input in the previous list.