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())
res = 0
ans = 0
maxNum = -1
for i in range(1,n+1):
    cnt = i
    res = 0
    while True:
        if i % 2 != 0:
            break
        else:
            i //= 2
            res += 1
    if maxNum < res:
        maxNum = res
        ans = cnt
print(ans)

Solution (Python):
a = int(input())
b = 1
c = 0
while True:
    b *= 2
    c += 1
    if b > a:
        print(b // 2)
        exit()

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

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

num = 1

while(N >= num*2):
    num *= 2

print(num)

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

alist = [2 ** i  for i in range(1, 10) if 2 ** i <= 100]

if n == 1:
    print(1)
    exit()

for i in range(n, 0, -1):
    if  i in alist:
        print(i)
        break

Solution (Python):
N = int(input())
ans = 0
for i in range(0, 7):
    ans = i if N >> i & 1 else ans
print(1<<ans)

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

Solution (Python):
from collections import Counter
n = int(input())
m = (1, 0)
for i in range(1, n+1):
    j = 0
    ii = i
    while ii % 2 == 0:
        ii /= 2
        j += 1
    if m[1] < j:
        m = (i, j)
print(m[0])

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

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

tp = 1
cnt = 0
while(tp <= n):
    tp *=2
    cnt+=1
    
print(pow(2,cnt-1))

Solution (Python):



n = int(input())
def count(n):
    c = 0
    while 1:
        if n % 2 == 0:
            n /= 2
            c += 1
        else:
            break
    return c

ma = 0
for i in range(1,n+1):
    if ma < count(i):
        ans = i
        ma = count(i)
if ma == 0:
    ans = 1
print(ans)

Solution (Python):
n=int(input())
ans=1
num=0
for i in range(1,n+1):
    check=i 
    c_num=0
    while check>0 and check%2==0:
        check//=2
        c_num+=1
    if num<c_num:
        num=c_num
        ans=i
print(ans)

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

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

Solution (Python):
n = int(input())
cnt = 0
ans = 1
for i in range(1, n + 1):
    c = 0
    rem = i
    while rem % 2 == 0:
        c += 1
        rem //= 2

    if c > cnt:
        cnt = c
        ans = i

print(ans)

Solution (Python):
N = int(input())
nums = [0 for _ in range(N+1)]

for n in range(1, N+1):
    if n % 2 == 0:
        nums[n] = nums[n//2] + 1

ans = 0
max_nums = max(nums)
for n in range(1, N+1):
    if nums[n] == max_nums:
        print(n)
        break

Solution (Python):
n=int(input())
ans_max=0
ans_num=0
for i in range(n):
    num=i+1
    num_now=i+1
    
    ans = 0
    while(num%2==0):
        num=num/2
        ans = ans+1
    if(ans>=ans_max):
        ans_max=ans
        ans_num=num_now
        
        

print(ans_num)

Solution (Python):

N = int(input())
if N == 1:
    print(N)
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())

now = 1
while True:

    now *= 2

    if now > N:
        print(now//2)
        break

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

Solution (Python):
n=int(input())
ans=0
ans_num=1
for i in range(1,n+1):
    count=0
    tmp=i
    while tmp%2==0:
        tmp//=2
        count+=1

    if ans<count:
        ans=count
        ans_num=i
print(ans_num)

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

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

if 2**0<=n<2**1:
    print(2**0)
elif 2**1<=n<2**2:
    print(2**1)
elif 2**2<=n<2**3:
    print(2**2)
elif 2**3<=n<2**4:
    print(2**3)
elif 2**4<=n<2**5:
    print(2**4)
elif 2**5<=n<2**6:
    print(2**5)
elif 2**6<=n<2**7:
    print(2**6)

Solution (Python):
N = int(input())
ans = 1
while N > 1:
    N //= 2
    ans *= 2

print(ans)

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

Solution (Python):
n=int(input())
o=0
def pi(a):
    ans=0
    while(a!=0):
        if a%2==1:
            i=0
            break
        a//=2
        ans+=1
    return ans
        
for i in range(1,n+1):
    u=pi(i)
    if u>=o:
        ans=i
        o=u
    u=0
print(ans)

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

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

Solution (Python):
def main():
    N = int(input())
    ans = 1
    while N > ans:
        ans *= 2
    if N == ans:
        print(ans)
    else:
        print(ans // 2)


main()

Solution (Python):
def main():
    N = int(input())
    ans = 1
    c = 0
    for n in range(N, -1, -1):
        cc = 0
        nn = n
        while nn % 2 == 0 and n > 0:
            nn //= 2
            cc += 1
        if cc > c:
            ans = n
            c = cc
    print(ans)


main()

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

if n==x:
    print(x)
else:
    print(x//2)

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

Solution (Python):
n = int(input())
bit = [2**i for i in range(10)]
print(max([j for j in bit if j <= n]))

Solution (Python):
n=int(input())
a=64
while a>n:
  a=a//2
print(a)

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

Solution (Python):
n=int(input())
ans=1
max=0
for i in range(1,n+1):
    cnt=0
    bin_str=bin(i)[2:]
    rev_bin=bin_str[::-1]
    
    for j in range(len(rev_bin)):
        if rev_bin[j]=="0":
            cnt+=1

    if cnt>max:
       max=cnt
       ans=i
print(ans)

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

if n >= 64:
    print(64)
elif n >= 32:
    print(32)
elif n >= 16:
    print(16)
elif n >= 8:
    print(8)
elif n >= 4:
    print(4)
elif n >= 2:
    print(2)
else:
    print(1)

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

Solution (Python):
class Get_set_num:
	def __init__(self):
		self.num = int()
		 
	def set_num(self,num):
		self.num = num

	def get_num(self):
		return self.num

		 
do  = Get_set_num()
Inp = input()
Inp = int(Inp)




max_list = [1,0]

for i in range(Inp , 1 , -1):
	count=0
	do.set_num(i)
	while i % 2 == 0:
		count += 1
		i= i/2
		if count > max_list[1]:
			max_list.clear()
			max_list.extend([do.get_num(),count])
			
print(max_list[0])

Solution (Python):


N = int(input())

for i in range(1, N + 1):
    if pow(2,i) > N:
        print(pow(2, i - 1))
        break

Solution (Python):


N = int(input())

if N >= 64:
    print(64)
elif N >= 32:
    print(32)
elif N >= 16:
    print(16)
elif N >= 8:
    print(8)
elif N >= 4:
    print(4)
elif N >= 2:
    print(2)
else:
    print(1)

Solution (Python):



n = int(input())

counter = 0
while 2 ** counter <= n:
    counter += 1

print(2 ** (counter - 1))

Solution (Python):
def main():
    N = int(input())
    ans = 1
    ct = 0
    while True:
        ct += 1
        ans = 2 ** ct
        if ans > N:
            break

    print(2 ** (ct-1))


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
res = -1
m = 0

if n == 1:
    print(1)
else:
    for i in range(1, n+1):
        a = i
        b = 0
        while a % 2 == 0:
            a = a // 2
            b += 1
        if b > m:
            m = b
            res = i
    print(res)

Solution (Python):
N = int(input())
while True:
    for i in range(7):
        b = 2**(6-i)
        if b <= N:
            break
    break
print(b)

Solution (Python):

from collections import defaultdict

def main():
    num = int(input())
    ans = 1

    while ans * 2 <= num:
        ans *= 2
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
max_n = 0
max_count = -1

for i in range(1, N+1):
    count = 0
    c = i
    while c % 2 == 0:
        c //= 2
        count += 1
    if count > max_count:
        max_n = i
        max_count = count

print(max_n)

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
for i in range(0,8):
    if 2**i > N:
        break
    ans = 2**i
print(ans)

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

if n==0:
    print(0)
    exit(0)
cnt=0
while n>0:
    n = n>>1
    if n>0:
        cnt = cnt + 1

print(1<<cnt)

exit(0)

Solution (Python):
n = int(input())
if n == 1:
  print('1')
elif 1 < n and n < 4:
  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):
a = 0
ans = 0
N = int(input())
for i in range(1, N+1) :
  p = 0
  x = i
  while x % 2 == 0 :
    x //= 2
    p += 1
  if a <= p :
    a = p
    ans = i
print(ans)

Solution (Python):
x=int(input())
i=1
while True:
    if 2**i > x:
        print(2**(i-1))
        exit()
    i+=1

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

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

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

ans=1

while True:
    if ans*2>n:
        break

    else:
        ans=ans*2

print(ans)

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

x=1

while True:
    if x*2>n:
        print(x)
        break
    else:
        x=x*2

Solution (Python):
def abc():
    n = int(input())
    ans = 1
    max_cnt = 0
    for i in reversed(range(1, n + 1)):
        cnt = 0
        tmp = i
        while True:
            if tmp % 2:
                break
            tmp //= 2
            cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
            ans = i
    print(ans)


abc()

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

Solution (Python):
N = int(input())
for i in range(9):
  a = 2**i
  if a <N:
    pass
    continue
  elif a >N:
    print(int(a/2))
    break

Solution (Python):
n=int(input());x=1
while 1:
    if x*2>n:
        print(x)
        break
    else:
        x=x*2

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

flg = 0
cnt = 0
cnt_max = 0
tmp = 0
out = 1

for i in range(1,n+1):
    tmp = i
    flg = 0
    cnt = 0
    while(flg==0):
        
        if tmp % 2 == 1:
            flg = 1
        else:
            tmp /= 2
            cnt += 1            
    if cnt > cnt_max:
        cnt_max = cnt
        out = i

print(out)

Solution (Python):
import sys

N = int(sys.stdin.readline().rstrip())

n = 1

while n <= N:
  n = n * 2

print(int(n/2))

Solution (Python):

numbers = int(input())

number_list = []
for num in range(numbers):
	number_list.append(num+1)


def how_many_times_divisible(n):
	
	count = 0
    
	while n % 2 == 0:
		
		n = n / 2
		
		count = count + 1
    
	return count
  



list_how_many_times_divisible = list(map(how_many_times_divisible,number_list))

index_number = list_how_many_times_divisible.index(max(list_how_many_times_divisible))


ans = index_number + 1
print(ans)

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")



N = int(sys.stdin.readline())
ans =1
while ans * 2 <=N:
    ans *= 2
print(ans)

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

maxcnt = 0
ans = 0
for i in range(1,n+1):
  cnt = 0
  for j in range(1,n):
    if i % 2**j == 0:
      cnt += 1
    else:
      if maxcnt < cnt:
        maxcnt = cnt
        ans = i
      else:
        break
if ans == 0:
  print(1)
else:
  print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())
for i in range(8):
    if n < 2**i:
        print(2**(i-1))
        sys.exit()

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

Solution (Python):

import sys


def solve(N: int):
    ret = 1
    while ret <= N:
        ret *= 2
    ret //= 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):

A = [1,2,4,8,16,32,64]
n = int(input())
ans = 0

for i in range(len(A)):
    if n >= A[i]:
        ans = A[i]
print(ans)

Solution (Python):
N = int(input())
ans = 1
while True:
    if N < ans:
        print(ans//2)
        break
    elif N == ans:
        print(ans)
        break
    else:
        ans *= 2

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

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

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

Solution (Python):




n = int(input())

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


print(ans)

Solution (Python):


n = int(input())
ans = 1
wari = 0

for i, tmp in enumerate(range(1, n+1)):
    aa = 0
    while tmp % 2 == 0:
        tmp = tmp // 2
        aa += 1
    if wari < aa:
        wari = aa
        ans = i+1

print(ans)

Solution (Python):
x=1
X=int(input())

for i in range(7):
    if 2**i<=X:x=2**i
print(x)

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

def main():
    tmp = curr = 1
    while True:
        tmp *= 2
        if N < tmp:
            break
        curr = tmp
    print(curr)

if __name__ == '__main__':
    main()

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

ans = 1

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

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

Solution (Python):
def count(i):
    cnt = 0
    switch = 1
    while switch:
        if i % 2 == 1:
            return cnt
        else:
            cnt += 1
            i = i / 2

n = int(input())
correct_num = 1
split_cnt = 0
for i in range(n):
    m = count(i + 1)
    if m >= split_cnt:
        correct_num = i + 1
        split_cnt = m
print(correct_num)

Solution (Python):
N = int(input())
M = 0
num = 1
for i in range(1, N+1):
    count = 0
    while i % 2 ==0:
        i = i / 2
        count = count + 1
    if count > M:
        M = count
        num = i * (2 ** count)
print(int(num))

Solution (Python):
N = int(input())
ans = 1
while N >= 2:
    N = N // 2
    ans *= 2

print(ans)

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

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

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

Solution (Python):
N = int(input())
ma = 1
for i in range(1, N + 1):
    count = 0
    while i % 2 == 0:
        i //= 2
        count += 1
    ma = max(ma, 1 << count)
print(ma)

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

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

max_div_cnt = 0
result = 1
for n in range(N):
  tmp = n + 1
  div_cnt = 0
  while tmp > 0:
    if tmp % 2 == 0:
      div_cnt += 1
      tmp //= 2
    else:
      break
  if div_cnt > max_div_cnt:
    max_div_cnt = div_cnt
    result = n + 1
print(result)

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

print(ans)

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

s = [2**i for i in range(10)]

while 1:
  if N in s:
    print(N)
    exit()
  N-= 1

Solution (Python):
n = int(input())
import math
i = int(math.log2(n))
print(2**i)

Solution (Python):
N = int(input())
ans = 0
for i in range(N):
    if N >= 2**i:
        A = 2**i
print(A)

Solution (Python):
n = int(input())
count = 0
for i in range(1,n+1):
    count1 = 0
    while i % 2 == 0 and i >= 2:
        count1 += 1
        i = i//2
    count = max(count,count1)
print(2**count)

Solution (Python):
n=int(input())
ans=0
for i in range(1,n+1):
    if(i%2 == 1):
        continue
    else:
        c = 0
        while(i%2!=1):
            c+=1
            i=i//2
        if(ans < c):
            ans=c
print(2**ans)

Solution (Python):
N = int(input())
X = []
for i in range(N):
    n = 0
    a = 0
    n = N - i
    while  n % 2 == 0:
        n = n // 2
        a = a + 1
    else:
        X.insert(0, a)
print(X.index(max(X)) + 1)

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

Solution (Python):
N = int(input())
A = int(0)
for i in range(N) :
    if N >= 2**i :
        A = 2**i

print(A)

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

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

while (c <= a):
	c = c * 2

print(int(c/2))

Solution (Python):
A=[1,2,4,8,16,32,64]
n=int(input())
a = 0
for i in range(len(A)):
    if n >= A[i]:
        a = A[i]
print(a)

Solution (Python):
a = int(input())
b = []
c = 1
while(c <= a):
     c = c*2
print(int(c/2))

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

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

Solution (Python):
n=int(input())
ans=[]
for i in range(7):
    if 2**i<=n:
        ans.append(2**i)

print(ans[-1])

Solution (Python):
intInp = int(input())
flag = True
maxValue = 1
tmp = 0
for i in range(1,intInp+1):
    
    tmpAns = i
    counter = 0
    while(True):
        if i % 2 == 0:
            
            counter += 1
            
            i /= 2
        else:
            
            if(counter > tmp):
                
                
                maxValue = tmpAns
                tmp = counter
            break
    
print(maxValue)

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

if n<2:
  print(n)
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):
from math import *
n = int(input())
k = int(log2(n))
print(2 ** k)

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

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

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

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

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

print(int(i/2))

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

k=0


while n//2>=1:
  k+=1
  n=n//2
 
print(2**k)

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

ans=1
max=0
cnt=0

for i in range(N):
    n = i+1
    cnt=0
    while(n%2==0):
        cnt+=1
        n=n//2
    if cnt>max:
        max=cnt
        ans=i+1
        
print(ans)

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

result = 1
max_c = 0
for i in range(1, n + 1):
    tmp = i
    count = 0
    while tmp > 0 and tmp % 2 == 0:
        tmp = int(tmp / 2)
        count += 1
    if max_c < count:
        max_c = count
        result = i

print(result)

Solution (Python):
import math
n = int(input())
curnum = 1
curmax = 0
for i in range(1, n + 1):
    c = int(math.log2(i))
    if c > curmax:
        curmax = c
        curnum = i
print(curnum)

Solution (Python):

def recurcive(N,c):
    if N%2==0 and N!=0:
        c+=1
        return recurcive(int(N/2),c)
    else:
        return c


N=int(input())
maxim=0

for i in range(1,N+1):
    if recurcive(i,0) > maxim:
        maxim=recurcive(i,0)
print(2**maxim)

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

ans = 1
while ans * 2 <= N:
    ans *= 2

print(ans)

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

res = -1
ans = -1
for i in range (1, N+1):
    count = 0
    a = i
    while a % 2 == 0:
        a /= 2
        count += 1
    
    if res < count:
        res = count
        ans = i

print(ans)

Solution (Python):
a = int(input())
l = list(range(1,a+1))
l1 = []
for i in l:
  count = 0
  while i % 2 == 0:
    i /= 2
    count += 1
  l1.append(count)
print(2**max(l1))

Solution (Python):
N = int(input())
count_list = []

for i in range(1,N+1):
    count = 0
    c = 1
    while c > 0:
        if i % 2 == 0:
            count += 1
            i /= 2
        else:
            c -= 1
    count_list.append(count)

print(2**max(count_list))

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

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

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

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

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

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

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

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

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

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

tmp = 0
cnt = 0
ans = 1

for i in range(1,n+1):
    s = i
    cnt = 0
    while True:
        if s % 2 == 0:
            cnt += 1
            s /= 2
        else:
            break
    if tmp < cnt:
        tmp = cnt
        ans = i

print(ans)

Solution (Python):


def solve():
    N = int(input())
    max_cnt = 0
    for i in range(N, 0, -1):
        cnt = 0
        num = i
        while True:
            if num == 1:
                print(i)
                return
            if num%2 == 0:
                num //=  2
                cnt += 1
                continue
            if cnt > max_cnt:
                max_cnt = cnt
                ans = i
            break
    print(ans)


if __name__ == "__main__":
    solve()

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

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

Solution (Python):
import math

N = int(input())

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

Solution (Python):
import math
N = int(input())
print(2**math.floor(math.log2(N)))

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

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

Solution (Python):

N=int(input())


c=0


a=1

for x in range(1,N+1):
  _c=0
  _x=x
  while True:
    if _x%2==0:
      _x//=2
      _c+=1
    else:
      if c<_c:
        c=_c
        a=x
      break


print(a)

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)
elif N<=100:
    print(64)

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

Solution (Python):


n = int(input())
j = 0
i = 0
for i in range(0, 8):
        j = 2 ** i
        if j <= n:
                max = j
print(max)

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

Solution (Python):
N=int(input())
power2 = [1,2,4,8,16,32,64]
ans=0
for i in power2:
    if N >=i:
        ans=i
print(ans)

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

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    cnt=0
    p=int(i+1)
    while p%2==0:
        cnt+=1
        p=p//2
    l.append([i+1,cnt])
l.sort(key=lambda x:x[1])
print(l[-1][0])

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

max_cnt = 0
res = 1
for i in reversed(range(1, N+1)):
    tmp = i
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        res = tmp
print(res)

Solution (Python):
n = int(input())
a = 1
while True:
  a = a * 2
  if a > n:
    ans = a // 2
    break
print(ans)

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

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

Solution (Python):
n = int(input())
power_2 = [2**i for i in range(1, 8)]
for i, power in enumerate(power_2):
  if n == 1:
    print(1)
    break
  elif n < power:
    print(power_2[i-1])
    break

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

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

for i in range(8):
    if 2 ** i <= N:
        pass
    else:
        break

print(2 ** (i - 1))

Solution (Python):
x = int(input())
l = [2**i for i in range(10)]
print(max([i for i in range(x,0,-1) if i in l]))

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

Solution (Python):

N = int(input())
count = 0
for _ in range(N):
    if N == 1:
        print(2**count)
        break  
    N //= 2
    count += 1
    if N ==1:
        print(2**count) 
        break

Solution (Python):
N = int(input())
ans = 1
while True:
  if 2 * ans > N:
    break
  ans *= 2
print(ans)

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

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

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

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

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

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    j=i+1
    c=0
    for _ in range(n):
        if  j%2==0:
            c+=1
            j=j/2       
        else:
            l.append(c)
            break
print(2**max(l))

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

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

print(ans)

Solution (Python):
N = int(input())
count = 0
counter = []

for i in range(1, N+1):
    num = i
    while num % 2 == 0:
        count += 1
        num /= 2
    counter.append([count, i])
    count = 0

counter.sort()
counter.reverse()

print(counter[0][1])

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

Solution (Python):
print((lambda n:sorted([2**i for i in range(7)],key=lambda x:x<=n)[::-1][0])(int(input())))

Solution (Python):
n = int(input())
result = []
for i in range(1, n+1):
  tmp = 0
  while i % 2 == 0:
    tmp += 1
    i = i / 2
  result.append(tmp)
print(result.index(max(result))+1)

Solution (Python):
n = int(input())
cnt_list = []
for i in range(1, n+1):
    cnt = 0
    while i % 2 == 0:
        i = i / 2
        cnt += 1
    cnt_list.append(cnt)
print(2**max(cnt_list))

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

if 1==n:
    print("1")
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())
X = 1
while(N>=X):
  X = X<<1
print(X>>1)

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

count = 0

while N != 1:
    count += 1
    N = N//2

print(2**count)

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

o = []
while N > 0:
    o.append(N%2)
    N //= 2

print(2**(len(o)-1))

Solution (Python):


def solve(n):
  ret = 1
  while True:
    if ret*2 > n:
      return ret
    else:
      ret *= 2

if __name__ == "__main__":
  n = int(input())
  print(solve(n))

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

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

Solution (Python):

n = int(input())
count = 0
while n > 1:
    n //= 2
    count += 1
print(2 ** count)

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

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

Solution (Python):
import sys
from collections import Counter

n = int(input())

for i in range(n, 0, -1):
    if i & (i-1) == 0:
        print(i)
        sys.exit()

Solution (Python):


def read_input():
    n = int(input())
    return n

def div_2(x, memo):
    
    if x in memo.keys():
        return memo[x], memo

    if x % 2 == 0:
        c, memo = div_2(x/2, memo)
        count = 1 + c
        memo[x] = count
        return count, memo

    return 0, memo

def submit():
    n = read_input()

    div_memo = {}
    for i in range(1, n + 1):
        _, div_memo = div_2(i, div_memo)

    counts = list(div_memo.items())
    counts.sort(key=lambda x:x[1], reverse=True)

    if not counts:
        print(1)
    else:
        print(counts[0][0])

if __name__ == '__main__':
    submit()

Solution (Python):
n = int(input())
cnt=1
while True:
    if 2**cnt <= n:
        cnt += 1
    else:
        print(2**(cnt-1))
        break

Solution (Python):
N = int(input())
x = [2,4,8,16,32,64]
for i in range(1,N+1)[::-1]:
    if i in x:
        print(i)
        exit()
print(1)