No Idea!

  • + 0 comments
    from collections import Counter 
    
    def happy_counter(array, A, B):
        array_count=Counter(array) # Count how many times each integer is repeated in array
        
        repeated=0
        for integer in array_count.keys():
            # Only considering repeated terms, check if they are in A or B
            value=array_count[integer]-1 
            if value!=0:
                if integer in A:
                    repeated+=value
                elif integer in B:
                    repeated-=value
                    
        # Non repeated terms are accounted for using the intersection method
        non_repeated=len(A.intersection(set(array)))-len(B.intersection(set(array)))
        return non_repeated+repeated
    
    if __name__ == '__main__':
        n, m=list(map(int, input().split()))
        array= list(map(int, input().split())) 
        A=  set(map(int, input().split()))
        B=  set(map(int, input().split()))
        print(happy_counter(array, A, B))