Problem:
 Score : 200 points    Problem Statement Takahashi loves numbers divisible by 2 .  You are given a positive integer N . Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2 , is how many times the integer can be divided by 2 without remainder.  For example,   6 can be divided by 2 once: 6 -> 3 .  8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1 .  3 can be divided by 2 zero times.       Constraints  1 ≤ N ≤ 100         Input Input is given from Standard Input in the following format:  N       Output Print the answer.        Sample Input 1 7      Sample Output 1 4  4 can be divided by 2 twice, which is the most number of times among 1 , 2 , ..., 7 .       Sample Input 2 32      Sample Output 2 32       Sample Input 3 1      Sample Output 3 1       Sample Input 4 100      Sample Output 4 64

Solution (Python):
N = int(input())

pivot = 0

while True:
  if 2 ** (pivot+1) <= N:
    pivot += 1
  else:
    break 

print(2 ** pivot)

Solution (Python):
n = int(input())
a = 1
while a * 2 <= n:
  a *= 2
print(a)

Solution (Python):
N=int(input())
i=0
while 2**i<=N:
    i+=1

print(2**(i-1))

Solution (Python):

N = int(input())
num = 0
Max = 0
Max_num = 0
cou = 0

for i in range(1,N+1):
    num = i
    cou = 0
    while num % 2 == 0:
        num = int(num/2)
        cou +=1
    if Max <= cou:
        Max = cou
        Max_num = i

print(Max_num)

Solution (Python):
n=int(input())
c=1
i=1
while n>=2**i:
  c=2**i
  i+=1
print(c)

Solution (Python):
N = int(input())

for i in range(7):
    if 2 ** i <= N < 2 ** (i + 1):
        print(2 ** i)

Solution (Python):
n=int(input())

count_list=[]
for i in range(1,n+1):
    count=0
    while True:
        
        if i%2==0:
            i//=2
            count+=1
        else:
            break
    count_list.append(count)

print(count_list.index(max(count_list))+1)

Solution (Python):
n = int(input())
ans = 1
while ans <= n/2:
  ans *= 2
print(ans)

Solution (Python):
N = int(input())
i = 0
while N >= 2**i:
    
    i+=1
print(2**(i-1))

Solution (Python):
N = int(input())
ans = 1

for n in range(N):
  ans*=2
  if ans>N:
    print(int(ans/2))
    exit()

Solution (Python):
N = int(input())
A = 1
while A <= N:
    A *= 2
print(A // 2)

Solution (Python):
N = int(input())
l_cnt = [1, 2, 4, 8, 16, 32, 64]
l_ans = [x for x in l_cnt if x <= N]

print((l_ans[-1]))

Solution (Python):
n = int(input())
m = 1
while m * 2 <= n:
    m *= 2
print(m)

Solution (Python):
N = int(input())

x = 1
while x * 2 <= N:
    x *= 2
print(x)

Solution (Python):
N = int(input())
a = 1
while a <= N:
    a *= 2
print(a // 2)

Solution (Python):
from math import log2
print(2**int(log2(int(input()))))

Solution (Python):
lst=[2**i for i in range(0,7)]
lst=sorted(lst,reverse=True)

n=int(input())
for i in lst:
    if i<=n:
        print(i)
        break

Solution (Python):
n = int(input())

i = 0
while(True):
  if 2**i > n:
    print(2**(i-1))
    break
  else :
    i += 1

Solution (Python):
import numpy as np
N = int(input())
ans = 2 ** int(np.log2(N))
print(ans)

Solution (Python):
n = int(input())
lst = [1,2,4,8,16,32,64,1000]
for i in range(7):
  if lst[i] <= n < lst[i + 1]:
    print(lst[i])
    exit()

Solution (Python):

n = int(input())

ans = 1
anscnt = 0

for i in range(1,n+1):
    a = i
    cnt = 0
    flg = True
    
    while flg:
        if a % 2 > 0:
            flg = False
        else:
            a /= 2
            cnt += 1
    
    if cnt > anscnt:
        ans = i
        anscnt = cnt

print(ans)

Solution (Python):
n = int(input())
ans = 1
while ans * 2 <= n:
    ans *= 2
print(ans)

Solution (Python):
pow2 = [2 ** i for i in range(0, 7)]
n = int(input())
res = max([i for i in pow2 if i <= n])
print(res)

Solution (Python):
import sys

pow2 = [2 ** i for i in range(0, 7)]
pow2.reverse()
n = int(input())
for i in pow2:
    if i <= n:
        print(i)
        sys.exit(0)

Solution (Python):
n=int(input())
for i in range(8):
  if 2**i > n:
    print(2**(i-1))
    break

Solution (Python):
N = int(input())
ans = 1
while ans*2 <= N:
    ans *= 2
print(ans)

Solution (Python):
"""abc068_b"""
N = int(input())

for i in range(8):
    if N < 2**i:
        print(2**(i-1))
        break

Solution (Python):


N = int(input())

ans = 1
tmp_i = 0
counter = 0
max_counter = 0

for i in range(1, N + 1):
    counter = 0
    tmp_i = i
    
    while tmp_i % 2 == 0:
        tmp_i = tmp_i / 2
        counter += 1
    if counter > max_counter:
        ans = i
        max_counter = counter

print(ans)

Solution (Python):
N = int(input())
j = 0
while 1:
    if 2**j > N:
        print(2**(j-1))
        break
    else:
        j += 1

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    res = 0

    def div2(num):
        if num == 1:
            return 0
        else:
            cnt = 0
            while True:
                if num % 2 == 0:
                    num //= 2
                    cnt += 1
                else:
                    return cnt


    res_max_cnt = 0
    res = 1
    for i in range(N):
        tepm_cnt = div2(i+1)
        if res_max_cnt < tepm_cnt:
            res_max_cnt = tepm_cnt
            res = i+1
    print(res)

if __name__ == "__main__":
    resolve()

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    res = 0

    def div2(num):
        if num == 1:
            return 1
        else:
            cnt = 0
            while True:
                if num % 2 == 0:
                    num //= 2
                    cnt += 1
                else:
                    return cnt


    res_max_cnt = 0
    for i in range(N):
        tepm_cnt = div2(i+1)
        if res_max_cnt <= tepm_cnt:
            res_max_cnt = tepm_cnt
            res = i+1
    print(res)

if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
a = 0
b = 0
for i in range(10):
  a = 2 ** i
  if a > n :
    print(b)
    break
  else:
    b = a

Solution (Python):
N = int(input())

result = 0
temp = 1
while temp <= 100:
    if temp <= N:
        result = temp
    temp *= 2

print(result)

Solution (Python):
import bisect

two_squares = [1]

temp = 1
while temp <= 100:
    temp *= 2
    two_squares.append(temp)

N = int(input())

result = bisect.bisect_right(two_squares, N)

print(two_squares[result - 1])

Solution (Python):
n = int(input())

ans = 1
i = 2
while i <= n:
    ans = i
    i *= 2

print(ans)

Solution (Python):
N=int(input())
print(1<<N.bit_length()-1)

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
n = int(input())
if n == 1:
    print(1)
elif n < 4:
    print(2)
elif n < 8:
    print(4)
elif n < 16:
    print(8)
elif n < 32:
    print(16)
elif n < 64:
    print(32)
else:
    print(64)

Solution (Python):
N=int(input())
for i in range(6,-1,-1):
  k = 2**i
  if N >= k:
    print(k)
    exit()

Solution (Python):
n=int(input())
if n==1:
    print(1)
    exit()

for i in range(6):
    if 2**(i+1)<=n:
        ans=2**(i+1)
        
print(ans)

Solution (Python):
n=int(input())
a=[2**i for i in range(7)]
ans=1
for i in a:
    if i in range(1,n+1):
        ans=i
print(ans)

Solution (Python):
n=int(input())
 
k=1
while n>=k:
  k=k*2
  
if k!=1:
  k=k//2

print(k)

Solution (Python):
n=int(input())

a=1
while a*2<=n:
  a*=2

print(a)

Solution (Python):
n = int(input())
ans = 1
while ans*2<=n:
  ans *=2
print(ans)

Solution (Python):
n=int(input())

list=[i for i in range(1,n+1)]


c_list=[]
for i in range(n):
    count=0
    num=list[i]
    while True:
        if num%2==0:
            num//=2
            count+=1
        else:
            break
    c_list.append(count)
    
print(list[c_list.index(max(c_list))])

Solution (Python):
n = int(open(0).read())

print(2 ** (n.bit_length() - 1))

Solution (Python):
l = list(range(1, int(input()) + 1))

cnt_l = []
for i in l:
  cnt = 0
  while i%2 == 0:
    i = i // 2
    cnt += 1
  cnt_l.append(cnt)

print(l[cnt_l.index(max(cnt_l))])

Solution (Python):

N = int(input())

i = 0
while 2**i <= N:
    i += 1
print(2**(i-1))

Solution (Python):
n = int(input())

x = 1
cnt = 1
while x <= n:
  x = 2 ** cnt
  cnt += 1
print(x//2)

Solution (Python):
N = int(input())
c = 0
while N>1:
  N = N//2
  c += 1
print(2**c)

Solution (Python):
N = int(input())
l = []
for i in range(1, N+1):
    count = 0
    while i % 2 == 0:
        count += 1
        i //= 2
    else:
        l.append(count)

print(l.index(max(l))+1)

Solution (Python):
N = int(input())
Num = [int(2**i) for i in range(7)]
if N in Num:
  print(N)
else:
  Num.append(N)
  Num = sorted(Num)
  print(2 ** (Num.index(N) - 1))

Solution (Python):
N = int(input())
if N < 2:
  print(N)
elif 2<=N<4:
  print(2)
elif 4<=N<8:
  print(4)
elif 8<=N<16:
  print(8)
elif 16<=N<32:
  print(16)
elif 32<=N<64:
  print(32)
elif 64<=N:
  print(64)

Solution (Python):
n = int(input())
ans = 1
while ans * 2 <= n:
    ans *= 2
print(ans)

Solution (Python):
N=int(input())

X=1
while X<=N:
    X*=2
print(X//2)

Solution (Python):
n=int(input())
ex=1
for i in range(n):
  if ex*2>n:
    break
  ex=ex*2
print(ex)

Solution (Python):
N = int(input())
x=0
while(N > 2**x):
    x+=1

if(N==1):
    print(1)
elif(N==2**x):
    print(2**x)
else:
    print(2**(x-1))

Solution (Python):
n = int(input())
a = 0
x = 1
for i in range(1,n+1):
    cnt = 0
    m = i
    while i %2 ==0:
        i = i//2    
        cnt = cnt +1
    
    while a < cnt:
        a = cnt
        x = m

print (x)

Solution (Python):
N = int(input())
a = 1

while a*2 <= N:
    a *= 2
print(a)

Solution (Python):
N = int(input())

ans = 1

while True:
    new = ans*2
    if new > N:
        print(ans)
        break
    else:
        ans = new

Solution (Python):
import sys
n = int(input())
ln = [64, 32, 16, 8, 4, 2, 1]
for i in ln:
    if i <= n:
        print(i)
        sys.exit()

Solution (Python):
n = int(input())
ans = 0

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for i in range(n + 1):
    k = factorization(i)
    for j in k:
        if j[0] == 2:
            if ans < j[1]:
                ans = j[1]
print(2 ** ans)

Solution (Python):
n = int(input())

for i in range(10):
    if 2 ** i > n:
        ans = 2 ** (i - 1)
        break

print(ans)

Solution (Python):
N=int(input())
for i in range(8):
  if pow(2,i)>N:
    print(pow(2,i-1))
    break

Solution (Python):
N = int(input())

if N < 2:
    print(1)
elif N >= 2 and N < 2**2:
    print(2)
elif N >= 2**2 and N < 2**3:
    print(2**2)
elif N >= 2**3 and N < 2**4:
    print(2**3)
elif N >= 2**4 and N < 2**5:
    print(2**4)
elif N >= 2**5 and N < 2**6:
    print(2**5)
elif N >= 2**6:
    print(2**6)

Solution (Python):
import sys
N = int(input())
for i in range(0,7):
	if N == 1:
		print(1)
		sys.exit()
	elif N >= 64:
		print(64)
		sys.exit()
	elif N < 2**i:
		print(2**(i-1))
		sys.exit()

Solution (Python):
n = int(input())
m = [64,32,16,8,4,2,1]
for i in m:
  if n >= i:
    print(i)
    break

Solution (Python):
n = int(input())
if n == 1:
  print(1)
elif n == 2 or n == 3:
  print(2)
elif 3 < n < 8:
  print(4)
elif 7 < n < 16:
  print(8)
elif 15 < n < 32:
  print(16)
elif 31 < n < 64:
  print(32)
else:
  print(64)

Solution (Python):
import sys
N = int(input())
if N < 0 or N > 100:
    sys.exit()

max = 0
answer = 1
for I in reversed(range(N+1)):
    if I % 2 == 0:
        result = I
        count = 0
        for J in range(I):
            if result % 2 == 0:
                result = int(result/2)
                count += 1
            if max <= count:
                max = count
                answer = I
print(answer)

Solution (Python):
def main():
  n=int(input())
  ans=1
  while ans*2<=n:
    ans*=2
    
  print(ans)
    
main()

Solution (Python):
s = int(input())
for i in range(s+1):
  if s < 2**i:
    print(2**(i-1))
    break

Solution (Python):
N = int(input())
a = 1

while a*2<=N:
  a*=2
  
print(a)

Solution (Python):
n = int(input())

count = 0
number = 0

for i in range(n+1):
    temp = 0
    j = i
    while j > 0 and j % 2 == 0:
        j //= 2
        temp += 1
    if temp >= count:
        count = temp
        number = i


print(number)

Solution (Python):
n = int(input())
cur = 0
ans = -1
for i in range(1,n+1):
    x = i
    counter = 0
    while x % 2 == 0:
        x /= 2
        counter += 1
    if cur <= counter:
        cur = counter
        ans = i
print(ans)

Solution (Python):










N = int(input())
i = 0
while 2 ** i <= N:
    i += 1

print(2**(i-1))

Solution (Python):
N = int(input())

arg = 1
maxscore = 0
for i in range(2, N+1):
    score = 0
    org = i
    while True:
        m = i % 2
        if m == 0:
            score += 1
            i //= 2
        else:
            if maxscore < score:
                arg = org
                maxscore = score
            break

print(arg)

Solution (Python):
N = int(input())
l = (N).bit_length()
print(1 << (l - 1))

Solution (Python):
N = int(input())
for i in range(N+1):
  if N < 2**i:
    print(2**(i-1))
    break

Solution (Python):
N = int(input())
ans = 1
while ans * 2 <= N:
    ans *= 2
print(ans)

Solution (Python):
n = int(input())
i = True
c = 1

while i:
    c *= 2
    if c > n:
        c = c // 2
        i = False

print(c)

Solution (Python):
N = int(input())

for i in range(6, -1, -1):
    if 2 ** i <= N:
        print(2 ** i)
        break

Solution (Python):
import math 
N = int(input())
Max = 0
for i in range(1,N+1):
    if math.log2(i).is_integer():
        e = int(math.log2(i))
        if e >= Max:
            Max = e
            ans = i
print(ans)

Solution (Python):
import math

print(2 ** int(math.log2(int(input()))))

Solution (Python):
n = int(input())

for i in range(1, 8, 1):
  if n < 2**i:
    print(2**(i-1))
    break

Solution (Python):
n = int(input())
num = 1
while num * 2 <= n:
    num *= 2

print(num)

Solution (Python):
N = int(input())
counter = 0
for i in range(8):
    if N // 2**i ==0:
        print(2**(i-1))
        break

Solution (Python):
n = int(input())
for i in range(7):
    if 2 ** i <= n:
        ans = 2 ** i
    else:
        break
print(ans)

Solution (Python):
N=int(input())
import numpy as np
print(2**int(np.log2(N)))

Solution (Python):
N = int(input())
if N == 1:
    print("1")
elif N == 2 or N == 3:
    print("2")
elif 4 <= N and N < 8:
    print("4")
elif 8 <= N and N < 16:
    print("8")
elif 16 <= N and N < 32:
    print("16")
elif 32 <= N and N < 64:
    print("32")
else:
    print("64")

Solution (Python):
n = int(input())

allcount = 0
if n == 1:
  print(1)
  exit()
for i in range(1,n+1):
  count = 0
  vans = i
  while True:
    if i%2 == 1:
      break
    elif i%2 == 0:
      count += 1
      i //= 2

  if count > allcount:
    allcount = count
    ans = vans

print(ans)

Solution (Python):
N,a=int(input()),1
while a*2<=N:a*=2
print(a)

Solution (Python):
N,a=int(input()),1
while a*2<=N:a=a*2
print(a)

Solution (Python):
N = int(input())
count = 0
cList = {}
s = 0
for i in range(1,N + 1):
    s = i
    while i % 2 != 1:
        i /= 2
        count += 1
    
    cList[s] = count
    count = 0


print(max(cList,key=cList.get))

Solution (Python):
a = input()
a = int(a)
def f(x):
    t = 0
    while x%2==0:
        t+=1
        x//=2
    return t
print(max((i for i in range(1,a+1)) ,key=f) )

Solution (Python):
N = int(input())
count = 0
scores = {}

for i in range(1, N + 1):
    I = i
    while(i % 2 == 0):
        i /= 2
        count += 1
    i = I
    scores[i] = count
    count = 0

print(max(scores, key = scores.get))

Solution (Python):

N = int(input())

for i in range(10):
    if 2**i > N:
        break
print(2**(i-1))

Solution (Python):
n = int(input())
ans = 1
for i in range(7):
  if 2 ** i <= n: ans = 2 ** i
print(ans)

Solution (Python):
n=int(input())
ans=1
while ans<=n:
    ans*=2
if ans>n:
    print(int(ans/2))
else:
    print(ans)

Solution (Python):
N = int(input())
n = 1
while n <= N:
    n *= 2
print(n//2)

Solution (Python):
n = format(int(input()),'b')
print(int('1'.ljust(len(n),'0'),2))

Solution (Python):
N = int(input())
a = 0

if N == 1:
    print(1)
elif N <4:
    print(2)
elif N<8:
    print(4)
elif N<16:
    print(8)
elif N<32:
    print(16)
elif N<64:
    print(32)
elif N<=100:
    print(64)

Solution (Python):
def resolve():
    n = int(input())
    ans = int()
    for i in range(7):
        if 2 ** i <= n and n < 2 ** (i+1):
            ans = 2 ** i
            print(ans)
            break
resolve()

Solution (Python):
n = int(input())
cnt = 0
ans = 1

for i in range(1,n+1):
    num = i
    tmp_cnt = 0
    while num % 2 == 0:
        num = num//2
        tmp_cnt += 1
    if cnt < tmp_cnt:
        cnt = tmp_cnt
        ans = i

print(ans)

Solution (Python):
n = int(input())
i = []
for p in range(n):
  i.append(0)
  a = p + 1
  while True:
    if a % 2 != 0:
      break
    else:
      i[p] += 1
      a = a / 2
print(i.index(max(i)) + 1)

Solution (Python):
N=int(input())
max=0
ans=1
num=0
for i in range(N):
    num=i+1
    count=0
    while True:
        if num%2==0:
            count+=1
        else:
            if max<count:
                max=count
                ans=i+1
            break
        num=num/2
print(ans)

Solution (Python):
n = int(input())

count = 0
list_count = []
max_number = 0

for i in range(n):
    a = i + 1
    while a % 2 == 0:
        count += 1
        a /= 2
    list_count.append(count)
    if max(list_count) == count:
        max_number = i + 1
    count = 0

print(max_number)

Solution (Python):
n=int(input())
i=1
while i*2<=n:
  i*=2
print(i)

Solution (Python):



def main():
    n = int(input())
    dic = {}
    for i in range(n):
        tmp = 0
        num = i+1
        for j in range(7):
            num = num/2
            if num.is_integer():
                tmp+=1
            else:
                break
        dic[i+1] = tmp
    print(max(dic, key=dic.get))

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
n = 0
while True:
    if 2 ** n > N:
        print(2 ** (n - 1))
        break
    n += 1

Solution (Python):
N=int(input());n=0;print([2**i for i in range(N) if 2**i<=N][-1])

Solution (Python):
N=int(input());n=0
for i in range(N):
  if 2**i<=N: n=2**i
print(n)

Solution (Python):
N=int(input());result=0
for i in range(N):
  if 2**i <= N: result = 2**i
print(result)

Solution (Python):
def check(num):
  count = 0
  while True:
    if num % 2 != 0:
      return count
    num //= 2
    count += 1

N = int(input())
if N==1: print(1);exit()
max_num = 0
result_num = 0
count = 0
for i in range(1, N+1):
  count = check(i)
  if max_num < count:
    max_num = count
    result_num = i
print(result_num)

Solution (Python):




from __future__ import division, print_function 

import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io


"""Uncomment modules according to your need"""













if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip



"""value of mod"""
MOD = 998244353
mod = 10**9 + 7

"""Uncomment next 4 lines if doing huge recursion"""




def prepare_factorial(mod=mod):
    """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """
    
    fact = [1]
    for i in range(1, 200005):
        fact.append((fact[-1] * i) % mod)

    ifact = [0] * 200005
    ifact[200004] = pow(fact[200004], mod - 2, mod)
    for i in range(200004, 0, -1):
        ifact[i - 1] = (i * ifact[i]) % mod

    return fact, ifact

def modinv(n, p):
    """ returns N inverse modulo p """
    return pow(n, p - 2, p)

def ncr(n, r,  fact, ifact):
    """ takes 4 arguments: n , r and factorial and inverse factorial lists"""
    t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD
    return t


def get_n(Sum):    
    """this function returns the maximum n for which Summation(n) <= Sum"""
    ans = (-1 + sqrt(1 + 8*Sum))//2
    return ans

def sieve(n):
    """ returns a list of prime numbers till n """
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r



def divs(n, start=1):
    """ returns a list of all divisors till n """
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors



def divn(n, primes):
    """ returns the number of divisors, two arguments n and the sieve till n """
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t



def lrfind(d, x, default=-1):
    """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return default, default
    else:
        return left, right

def gcd(x, y): 
    """ returns greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x

def check_sorted(a):
    ''' returns True/False '''
    for i in range(len(a)-1):
        if a[i]>a[i+1]:
            return False
    return True
def ceil(n, k=1): return n // k + (n % k != 0) 
def input(): return sys.stdin.readline().strip()
def ii(): return int(input()) 
def mi(): return map(int, input().split()) 
def li(): return list(map(int, input().split())) 
def lw(): return input().split() 
def lcm(a, b): return abs(a * b) // gcd(a, b) 
def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) 
def dd(): return defaultdict(int) 
def ddl(): return defaultdict(list) 
def write(s): return sys.stdout.write(s)













def main():
    
    n=ii()
    i=1
    while(i*2<=n):
        i*=2
    if i>n:
        print(i//2)
    else:
        print(i)














""" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------"""

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill();
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):

    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode('ascii'))
            self.read = lambda: self.buffer.read().decode('ascii')
            self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')



""" main function"""

if __name__ == '__main__':
    main()

Solution (Python):
import sys
N = int(input())
evens = [i for i in range(1, N+1) if i%2 ==0]
even_cnts = []
if evens == []:
    print(1)
    sys.exit()
for even in evens:
    cnt = 0
    while even % 2 ==0:
        cnt += 1
        even = even / 2
    even_cnts.append(cnt)
max_cnts = max(even_cnts)
index = even_cnts.index(max_cnts)
print(evens[index])

Solution (Python):
N = int(input())
k = 0

while True:
    if 2**k > N:
        break

    ans = 2 ** k
    k +=1
print(ans)

Solution (Python):
n = int(input())

ans = [1,2,4,8,16,32,64,128]

for i in range(10):
    if ans[i] > n:
        print(ans[i-1])
        exit()

Solution (Python):
N = int(input())
count = 0
for i in range(7):
    if 2**i <= N:
        count = 2**i
print(count)

Solution (Python):
N = int(input())
count = 0
for i in range(7):
    if 2**i <= N:
        count = 2**i
print(count)

Solution (Python):
a = int(input())
if a>=64:
  print('64')
elif a>=32:
  print('32')
elif a>=16:
  print('16')
elif a>=8:
  print('8')
elif a>=4:
  print('4')
elif a>=2:
  print('2')
else:
  print('1')

Solution (Python):
n = int(input())
ans = 0
out = 1
for i in range(1, n + 1):
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    if cnt > ans:
        ans = cnt
        out = i * 2 ** ans
print(out)

Solution (Python):
n = int(input())
count = 0
for i in range(8):
    if 2**i <= n:
        count = 2**i
print(count)

Solution (Python):
n = int(input())
ans = 0
out = 1
for i in range(1, n + 1):
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    if cnt > ans:
        ans = cnt
        out = i * 2 ** cnt
print(out)

Solution (Python):
import math
n = int(input())

beki = math.floor(math.log(n,2))
x = 2**beki
print(x)

Solution (Python):
n = int(input())
count = 0
for i in range(8):
    if 2**i <= n:
        count = 2**i
print(count)

Solution (Python):
import sys
n=int(input())
if n==1:
    print(1)
    sys.exit()
k=2
ans=0
while k*2<=n:
    k*=2
    ans+=1
print(k)

Solution (Python):
n = int(input())
c = 1
if n < 3:
    print(n)
    exit()

for i in range(6):
    c = c*2
    if n < c*2:
        print(c)
        break

Solution (Python):
def waru(x):
  ret_val=0
  while x>0:
    if x%2:
      break
    else:
      x//=2
      ret_val+=1
  return ret_val

N=int(input())
check_val=0
ans=1
for i in range(1,N+1):
  temp=waru(i)
  if check_val<temp:
    check_val=temp
    ans=i
print(ans)

Solution (Python):
N = int(input())
if N == 1:
  print(1)
elif 2 <= N <= 3:
  print(2)
elif 4 <= N <= 7:
  print(4)
elif 8 <= N <= 15:
  print(8)
elif 16 <= N <= 31:
  print(16)
elif 32 <= N <= 63:
  print(32)
elif 64 <= N <= 100:
  print(64)

Solution (Python):
N=int(input())
ans=1
check=0
for i in range(2,N+1):
  count=0
  waru=i
  while waru>0:
    waru//=2
    if waru>0:
      count+=1
  if check<count:
    check=count
    ans=i
print(ans)

Solution (Python):
n = int(input())
x = len(bin(n))-3
print(2**x)

Solution (Python):
n = int(input())
count = 0
while 2**count <= n:
    x = 2**count
    count += 1
print(x)

Solution (Python):
n = int(input())
count = 0
while 2**count <= n:
    count += 1
print(2**(count-1))

Solution (Python):
n = int(input())
count = 0
for i in range (10):
    if 2**i <= n:
        count = 2**i
print(count)

Solution (Python):
N = int(input())

for i in range(1,8):
    if N < 2**i:
        print(2**(i-1))
        break

Solution (Python):
import math
n=int(input())

print(2**math.floor(math.log2(n)))

Solution (Python):
N = int(input())
count = 0
for i in range(10):
    if 2 ** i <= N:
        count = 2 ** i

print(count)

Solution (Python):
n=int(input())
if n<2:
    print(1)
elif n<4:
    print(2)
elif n<8:
    print(4)
elif n<16:
    print(8)
elif n<32:
    print(16)
elif n<64:
    print(32)
else:
    print(64)

Solution (Python):
a = int(input())
x = 0
while 2**x <=a:
    boxs = 2 ** x
    x += 1
print(boxs)

Solution (Python):

N=int(input())
k=0
while 2**k <= N:
    ans = 2**k
    k += 1
print(ans)

Solution (Python):
N=int(input())
k=0
while 2**k <= N:
    ans = 2**k
    k += 1
print(ans)

Solution (Python):
n = int(input())
for i in range(8):
  if 2 ** i > n:
    print(2**(i-1))
    break

Solution (Python):
def div2(N) : 
  num = 1
  while True : 
    if 2 * num > N : 
      return num
    num *= 2

N = int(input())

print(div2(N))

Solution (Python):
N = int(input())

ans = 1

while ans <= N :
    if N == ans:
        print(ans)
        break
    ans *= 2
if ans > N:
    print(int(ans/2))

Solution (Python):
n = int(input())

for i in range(6,0,-1):
  if n >= 2**i:
    print(2**i)
    exit()
print(1)

Solution (Python):
N = int(input())
res = 1
for i in range(8):
    if res * 2 > N:
        print(res)
        break
    res *= 2

Solution (Python):
n = int(input())
if n == 1:
    print(1)
elif n <= 3:
    print(2)
elif n <= 7:
    print(4)
elif n <= 15:
    print(8)
elif n <= 31:
    print(16)
elif n <= 63:
    print(32)
else:
    print(64)

Solution (Python):
n=int(input())
if n==1:
  print(1)
else:
  for i in range(n,1,-1):
    if i in [2,4,8,16,32,64]:
      print(i)
      break

Solution (Python):
n = int(input())

mxcnt = 0
ans = 1
for i in range(1,n+1):
    cnt = 0
    x = i
    for j in range(7):
        if x % 2 != 0:
            break
        cnt += 1
        x //= 2
    if cnt >= mxcnt:
        mxcnt = cnt
        ans = i
print(ans)

Solution (Python):
def resolve():
    N = int(input())
    ans = 1
    while ans <= N:
        ans *= 2
    print(ans//2)
resolve()

Solution (Python):
n = int(input())

k = 1
while True:
  if k <= n//2:
    k = 2 * k
  else:
    break

print(k)

Solution (Python):
n = int(input())
t = 1
while(t * 2 <= n):
    t = t * 2
print(t)

Solution (Python):
N=int(input())
list=[1,2,4,8,16,32,64]
if list.count(N)==1:
    print(N)
    exit()

list.append(N)
anslist=sorted(list)

print(anslist[anslist.index(N)-1])

Solution (Python):
def main():
    N = int(input())

    n = 1
    count = 0

    while True:
        n *= 2
        if n > N:
            break
        count += 1

    print(n // 2)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
res = 1
max = 0
for i in range(1, N+1):
    cnt = 0
    n = i
    while True:
        if n%2 != 0:
            break
        else:
            n = n//2
            cnt += 1
    if cnt > max:
        res = i
        max = cnt
print(res)

Solution (Python):
n = int(input())

num = 0

for i in range(1, n+1):
    for k in range(1, 8):
        if 2**k <= i:
            num = 2**k
        else:
            break

if num:
    print(num)
else:
    print(n)

Solution (Python):

n = int(input())
for i in range(0, 8):
  if 2 ** i <= n:
    pass
  else:
    print(2**(i-1))
    break

Solution (Python):


N = int(input())

for i in range(8):
    if pow(2, i) <= N:
        ans = pow(2, i)
    else:
        break
print(ans)

Solution (Python):
n = int(input())
total = {}
for i in range(1, n+1):
    a = i
    cnt = 0
    while a % 2 == 0:
        a /= 2
        cnt += 1
    total[i] = cnt

total = sorted(total.items(), key=lambda x:x[1])
print(total[-1][0])