Here is my C++ code, which always TLE:

```
class Solution {
public:
int firstBadVersion(int n) {
int l = 1, r = n;
while (l < r) {
int mid = (l+r)/2;
if (isBadVersion(mid)) {
r = mid;
} else {
l = mid +1;
}
}
return l;
}
};
```

Here is my python code, the same binary search algo as C++, but this solution is accepted:

```
def firstBadVersion(n):
l = 1
r = n
while l < r:
mid=(l+r)/2
if isBadVersion(mid):
r = mid
else:
l = mid+1
return l
```