二分探索に関する問題です.
# ITP2_6_A
# 二分探索の関数
def binary_search(n,N):
    left = 0
    right = len(N)-1
    while left <= right:
        half = int((right + left)/2)
        if N[half] == n:
            return 1
        # n が half より左側にある
        elif N[half] > n:
            right = half-1
        # n が half より右側にある
        elif N[half] < n:
            left = half+1
            
    return 0
dummy = int(input())
N = list(map(int,input().split(" ")))
m = int(input())
for _ in range(m):
    n = int(input())
    print(binary_search(n,N))
    ITP2_6_Cでbisect_leftと同じ処理を書きますが,bisect_leftを使うことでも解くことができます.
    bisect_leftを使う場合は二分探索の処理を自分で書く必要はないです.
    
# ITP2_6_A
# bisect_left を使うやり方
from bisect import bisect_left
length = int(input())
N = list(map(int,input().split(" ")))
m = int(input())
for _ in range(m):
    n = int(input())
    b_left = bisect_left(N,n) # b_left: 順序を保ったままNにnを挿入できる位置
    if b_left <= length-1:
        print(int(n == N[b_left]))
    else:
        print(0)
    
# ITP2_6_B
n = int(input())
N = set(map(int,input().split(" ")))
m = int(input())
M = set(map(int,input().split(" ")))
# M <= N で包含関係を調べることができる
print(int(M <= N))
    
# ITP2_6_C
# lower boundを# ITP2_6_Aの二分探索を改良して求める
# 二分探索の関数
def binary_search(n,N):
    left = 0
    right = len(N)-1
    lower_bound = len(N) # 存在しない場合はNの長さ
    while left <= right:
        half = int((right + left)/2)
        # n が half より左側にある (一致しても同じ数字が左側にあるかもしれないことに注意)
        if N[half] >= n:
            right = half-1
            lower_bound = half # lower_boundを更新
        # n が half より右側にある
        elif N[half] < n:
            left = half+1
            
    return lower_bound
n = int(input())
N = list(map(int,input().split(" ")))
m = int(input())
for _ in range(m):
    k = int(input())
    print(binary_search(k,N))
    また,bisect_leftを使うことでも上と同じ処理ができます.
# ITP2_6_C
# bisect_left を使うやり方
from bisect import bisect_left
n = int(input())
N = list(map(int,input().split(" ")))
m = int(input())
for _ in range(m):
    k = int(input())
    print(bisect_left(N,k))
    
# ITP2_6_D
# 二分探索の関数 lower_bound
def binary_search(n,N):
    left = 0
    right = len(N)-1
    lower_bound = len(N) # 存在しない場合はNの長さ
    while left <= right:
        half = int((right + left)/2)
        # n が half より左側にある (一致しても同じ数字が左側にあるかもしれないことに注意)
        if N[half] >= n:
            right = half-1
            lower_bound = half # lower_boundを更新
        # n が half より右側にある
        elif N[half] < n:
            left = half+1
            
    return lower_bound
n = int(input())
N = list(map(int,input().split(" ")))
m = int(input())
for _ in range(m):
    k = int(input())
    # upper_bound が lower_boundより右なことを利用しなくても時間制限をクリアできました
    print(binary_search(k,N),binary_search(k+1,N))