class Solution:
    def firstBadVersion(self, n):
        """
        :type n: int
        :rtype: int
        """
        left=0
        right=n
        while (left<=right):
            mid =(left+right)//2
            if isBadVersion(mid):
                right=mid-1
            else:
                if isBadVersion(mid+1):
                    return mid+1
                else:
                    left=mid+1
22f2fc342a9e376a1e67e46d33735f72205ee2dc
<mask token>

class Solution:
    <mask token>

class Solution:

    def firstBadVersion(self, n):
        """
        :type n: int
        :rtype: int
        """
        left = 0
        right = n
        while left <= right:
            mid = (left + right) // 2
            if isBadVersion(mid):
                right = mid - 1
            elif isBadVersion(mid + 1):
                return mid + 1
            else:
                left = mid + 1

class Solution:
    def firstBadVersion(self, n):
        """
        :type n: int
        :rtype: int
        """
        left=0
        right=n
        while (left<=right):
            mid =(left+right)//2
            if isBadVersion(mid):
                right=mid-1
            else:
                if isBadVersion(mid+1):
                    return mid+1
                else:
                    left=mid+1