Problem:
Search II You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S. Input In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given. Output Print C in a line. Constraints  Elements in S is sorted in ascending order  n ≤ 100000  q ≤ 50000  0 ≤ an element in S ≤ 10 9  0 ≤ an element in T ≤ 10 9  Sample Input 1 5
1 2 3 4 5
3
3 4 1 Sample Output 1 3 Sample Input 2 3
1 2 3
1
5 Sample Output 2 0 Sample Input 3 5
1 1 2 2 3
2
1 2 Sample Output 3 2 Notes

Solution (Python):
def binary_search(a, n, query):
    start = 0
    end = n - 1
    while start <= end:
        mean = (start + end) // 2
        if a[mean] == query:
            return True
        elif a[mean] > query:
            end = mean - 1 
        else:
            start = mean + 1
    
    return False


n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]

count = 0
for i in t:
    if binary_search(s, n, i):
        count += 1

print(count)

Solution (Python):
n=int(input())
lista=[int(i) for i in input().split()]
n2=int(input())
listb=[int(i) for i in input().split()]
cnt=0


for i in listb:
    C=int(len(lista)/2)
    D=[0,len(lista)]
    while(1):
        if i<lista[C]:
            for k in D:
                if C>k:
                    d=k
                    break
            D.insert(0,C)
            C=int((C+d)/2)

        elif i>lista[C]:
            for k in D:
                if C<k:
                    d=k
                    break
            D.insert(0,C)
            C=int((C+d)/2)
        else:
            cnt+=1
            break
    
        if C==D[0]:
            break
    
        
print(cnt)

Solution (Python):
s = input()
snum = set(map(int, input().split()))
q = input()
qnum = set(map(int, input().split()))
print(len(snum & qnum))

Solution (Python):
n = int(input())
S = [int(l) for l in input().split(' ')]
kn = int(input())
T = [int(l) for l in input().split(' ')]

def binary_search(k,A,n):
  left = 0
  right = n
  while left < right:
    mid = (left + right)//2
    if A[mid] == k:
      return True
    elif A[mid] < k:
      left = mid + 1
    else:
      right = mid
  return False

sum = 0
for t in T:
  if binary_search(t,S,n):
    sum += 1
print(sum)

Solution (Python):
from bisect import bisect_left
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
ans = 0
for ele in t:
  i = bisect_left(s, ele)
  if s[i]==ele:
    ans += 1
print(ans)

Solution (Python):

input()
a=set(map(int,input().split()))
input()
b=set(map(int,input().split()))
print(len(a)-len(a-b))

Solution (Python):
n = int(input())
S = set([int(i) for i in input().split()])
q = int(input())
T = set([int(i) for i in input().split()])
print(len(S&T))