=====Problem Statement=====
There is an array of n integers. There are also 2 disjoint sets, A and B, each containing m integers. You like all the integers in set A and dislike all the integers in set B. Your initial happiness is 0. For each integer i in the array, if i ∈ A, you add 1 to your happiness. If i ∈ B, you add -1 to your happiness. Otherwise, your happiness does not change. Output your final happiness at the end.

Note: Since A and B are sets, they have no repeated elements. However, the array might contain duplicate elements.

=====Constraints=====
1≤n≤10^5
1≤m≤10^5
1≤Any integer in the input≤10^9

=====Input Format=====
The first line contains integers n and m separated by a space.
The second line contains n integers, the elements of the array.
The third and fourth lines contain m integers, A and B, respectively.

=====Output Format=====
Output a single integer, your total happiness.

Difficulty: introductory

Starter code:

# Enter your code here. Read input from STDIN. Print output to STDOUT

Solutions:
from collections import Counter
n, m = list(map(int,input().split()))
ar = list(map(int,input().split()))
ar_set = set(ar)
ar_counter = Counter(ar)
set_a = set(map(int,input().split()))
set_b = set(map(int,input().split()))
intersect_ar_a = list(ar_set&set_a)
intersect_ar_b = list(ar_set&set_b)
result = 0
for element in intersect_ar_a:
    result += ar_counter[element]
for element in intersect_ar_b:
    result -= ar_counter[element]
    
print(result)


#!/usr/bin/env python3

def __starting_point():
    happiness = 0
    n, m = map(int, input().strip().split(' '))
    arr = list(map(int, input().strip().split(' ')))
    
    good = set(map(int, input().strip().split(' ')))
    bad = set(map(int, input().strip().split(' ')))
    
    for el in arr:
        if el in good:
            happiness += 1
        elif el in bad:
            happiness -= 1
    
    print(happiness)
__starting_point()