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-----
7

-----Sample Output-----
4

4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.

Difficulty: introductory

Starter code:

Solutions:
#!/usr/bin/env python3
import sys


def solve(N: int):
    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))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

def __starting_point():
    main()

__starting_point()

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))


n = int(input())
x = 0
for i in range(1, n+1):
    if i%64 == 0 and 64 > x:
        ans = i
        x = 64
    elif i%32 == 0 and 32 > x:
        ans = i
        x = 32
    elif i%16 == 0 and 16 > x:
        ans = i
        x = 16
    elif i%8 == 0 and 8 > x:
        ans = i
        x = 8
    elif i%4 == 0 and 4 > x:
        ans = i
        x = 4
    elif i%2 == 0 and 2 > x:
        ans = i
        x = 2
    elif i == 1:
        ans = 1
        x = 1
print(ans)

n = int(input())
res = 1
while True:
    if res > n:
        break
    res *= 2
print((res // 2))


N = int(input())

def black_magic(n):
    d = {
        1: 1431655765,
        2: 858993459,
        4: 252645135,
        8: 16711935,
        16: 65535
    }
    n=(n&d[1])+((n>>1)&d[1])
    n=(n&d[2])+((n>>2)&d[2])
    n=(n&d[4])+((n>>4)&d[4])
    n=(n&d[8])+((n>>8)&d[8])
    n=(n&d[16])+((n>>16)&d[16])
    return n

while black_magic(N) - 1:
    N &= N-1
print(N)

s = int(input())
t = 1
for i in range(1,8,1):
  if(s >= (2 ** i)):t = 2 ** i
print(t)

print((2**(len(bin(int(input()))[2:])-1)))


N = int(input())

cnt_list = []
for i in range(1, N + 1):
    cnt = 0
    while i >= 1:
        if i % 2 == 0:
            cnt += 1
            i = i / 2
        else:
            break
    cnt_list.append(cnt)
M = cnt_list.index(max(cnt_list))
print(M + 1)

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

N = int(input())
num = 1
while num <= N:
  num *= 2
print(num // 2)

n = int(input())
i = 0

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

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

N = int(input())
for i in range(100):
    x = 2 ** (100 - i)
    if x <= 64 and x <= N:
        ans = x
        break
    else:
        ans = N
print(ans)

import bisect
n = int(input())
t = [1, 2, 4, 8, 16, 32, 64]

print(t[bisect.bisect_right(t, n)-1])

n = int(input())

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

if i > n:
    print((int(i / 2)))
else:
    print(i)


N = int(input())
ans = [1, 2, 4, 8, 16, 32, 64]
print(max(filter(lambda x : x<=N,ans)))

# -*- coding:utf-8 -*-
N = int(input())

if N == 1:
    print(N)
else:
    for i in range(1,8):
        if 2**(i+1) > N:
            print(2**i)
            break
        else:
            i+=1

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

N=int(input())
two=[2**i for i in range(7)]
ans=max([x for i,x in enumerate(two) if x<=N])
print(ans)

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

n = int(input())
count = [0] * n
for i in range(1, n + 1):
    num = i
    while num % 2 == 0:
        num //= 2
        count[i - 1] += 1
print(count.index(max(count)) + 1)

def cnt_div_two(n):
    res = 0
    while n % 2 == 0:
        n //= 2
        res += 1
    return res


ans = 0
max_cnt = -1
for i in range(1, int(input()) + 1):
    cdt = cnt_div_two(i)
    if cdt > max_cnt:
        ans = i
        max_cnt = cdt
print(ans)


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

def resolve():
    print(2 ** (len(bin(int(input()))) - 3))


def __starting_point():
    resolve()
__starting_point()

n=int(input())
ans=1

while(ans<=n):
    ans*=2

print(int(ans/2))

N = int(input())
count = 0
num = 1

while N >= num:
    count += 1
    num *= 2

print(num // 2)

print(1<<int(input()).bit_length()-1)

num = int(input())
ans = 1
while ans <= num:
    ans = ans * 2
print((int(ans/2)))


n = int(input())

a = 1
while a <= n:
  a *= 2
print(a//2)

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

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

print(ans)

n = int(input())
ans, cnt = 1, 0
for i in range(1, n+1):
    j = i
    t_cnt = 0
    if i%2 == 0:
        # print(i)
        while i%2 == 0:
            i = i//2
            t_cnt += 1
            # print(i, t_cnt)
        if t_cnt >= cnt:
            ans = j
            cnt = t_cnt

print(ans)

n=int(input())
for i in range(1,n+1):
    if 2**i>n:
        print((2**(i-1)))
        return
        


N=int(input())

X=[]


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

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


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


n=int(input())
m = 0
i = 0
while 2**i <= n:
  m = max(m, 2**i)
  i += 1
print(m)

N=int(input())
a=1
while(N>1):
  N//=2
  a*=2
print(a)

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

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
lis = [2**i for i in range(10)]
idx = bisect.bisect_right(lis, n)
print((lis[idx-1]))


N=int(input())
lis=[0]*(N+1)
Mcnt=0
Mi=1

for i in range(1,N+1):
  lis[i]=i
  cnt=0
  while lis[i]%2==0:
    lis[i]//=2
    cnt+=1
    
  if Mcnt<cnt:
    Mcnt=cnt
    Mi=i
    
print(Mi)

import math

N = int(input())

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

if i <= N:
  print(i)
else:
  print(math.floor(i/2))

n = int(input())
ans = 1

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

print(ans)

import math

n = int(input())
ans, i = 0, 1
while ans <= n:
    ans = 2**i
    i += 1

print(ans//2)

N = int(input())

if N == 1:
    print((1))
elif 1 < N < 2**2:
    print((2))
elif 2**2 <= N < 2**3:
    print((4))
elif 2**3 <= N < 2**4:
    print((8))
elif 2**4 <= N < 2**5:
    print((16))
elif 2**5 <= N < 2**6:
    print((32))
elif 2**6 <= N:
    print((64))



N = int(input())
N2 = N
a = []

for i in range(N):
    count = 0
    if i != 0:
        tmp = N
        while tmp % 2 == 0:
            tmp = tmp / 2
            count += 1

        N = N - 1
    a.append(count)

max_value = max(a)

ind = a.index(max_value)

if N2 == 1:
    print((1))
else:
    print((N2-ind+1))


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

N=int(input())
i=0
while pow(2, i+1)<=N:
  i+=1
print(pow(2, i))

n = int(input())
num = [i for i in range(1,n+1)]
jou = [2**j for j in range(0,7)]
for l in jou:
    if l in num:
        ans = l
    else:
        break
print(ans)

from math import log2

N = int(input())

m = 0
a = 0

for i in range(1, N + 1):
  l = log2(i)
  if l % 1 == 0:
    m = i


print(m)


#!/usr/bin/env python3

def main():
    n = int(input())
    i = 0
    while 2 ** i <= n:
        i += 1
    print((2 ** (i - 1)))


def __starting_point():
    main()

__starting_point()

n = int(input())
if n == 1:
  print(1)
else:
  for i in range(1,7):
    if 2**(7-i) <= n:
      print(2**(7-i))
      return

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


n = int(input())
s = [i for i in range(1,n+1)]
counter = 0
while(True):
    if len(s)==1:
        print((1))
        break
    if len([i for i in s if i % 2 == 0])==1:
        s = [i for i in s if i % 2 == 0]
        print((int(s[0]) * (2 ** counter)))
        break
    else:
        s = [i/2 for i in s]
        counter += 1


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

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


N = int(input())

ans = 0
res = 1
for i in range(2,N+1):
  j = i
  if j % 2 == 1:
    continue
  cnt = 0
  while j % 2 == 0:
    j //= 2
    cnt += 1
  if ans < cnt:
    res = i
    ans = cnt
  
print(res)

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

import math
n=int(input())
print(2**int(math.log(n,2)))

n = int(input())

cnt = 0
while n > 0:
  n = n // 2
  if n != 0:
    cnt += 1
print(2 ** cnt)

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

N = int(input())
ans_max = 0
ans = 1
for i in range(1, N + 1):
    cnt = 0
    moto_i = i
    while i % 2 == 0:
        cnt += 1
        if cnt > ans_max:
            ans = moto_i
        ans_max = max(ans_max, cnt)
        i //= 2
print(ans)


N=int(input())
result=64
while N>=1:
  if N >= result:
    print(result)
    break
  result=int(result/2)
else:
  print(result)

print(1<<len(f'{int(input()):b}')-1)

n = int(input())
li = [2,4,8,16,32,64]
import bisect
index = bisect.bisect(li,n)-1
import sys
if index == -1:
    print(n)
    return
print(li[index])

n=int(input())
ans=0
for i in range(7):
    if (n>>i)&1:
        ans=(n>>i)<<i
print(ans)

n = int(input())
max_count, answer = 0, 0
for i in range(1, n + 1):
    num = i
    count = 0
    while num % 2 == 0:
        num = num // 2
        count += 1
    if count > max_count:
        max_count, answer = count, i

print((max(1, answer)))


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

import math


def answer(n: int) -> int:
    return 2 ** int(math.log(n, 2))


def main():
    n = int(input())
    print(answer(n))


def __starting_point():
    main()
__starting_point()

N = int(input())

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

print(ans//2)

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

N = int(input())
ans = []
for i in range(N):
    q = i+1
    count = 0
    if q == 1:
        continue
    while True:
        if q%2 != 0:
            break
        q = q//2
        count += 1
    ans.append(count)

if len(ans) > 0:
    max_count = max(ans)
    print(ans.index(max_count)+2)
else:
    print(1)

def solve(n):
  res = 0
  while(n != 1):
    if n%2 == 0:
      res += 1
      n /= 2
    else:
      break
  return res

n = int(input())

ans = 1
ans_max = 0
for i in range(1, n+1):
  cnt = solve(i)
  if cnt > ans_max:
    ans_max = cnt
    ans = i
print(ans)

N = int(input())
L = [64, 32, 16, 8, 4, 2]
for i in L:
  if i <= N:
    print(i)
    break
else:
  print(N)

#!/usr/local/bin/python3
# https://atcoder.jp/contests/abc068/tasks/abc068_b
import math

def fact(N):
    ans = {}
    for i in range(2, math.ceil(math.sqrt(N))+1):
        if N % i != 0:
            continue
        ex = 0

        while N % i == 0:
            ex += 1
            N /= i
        ans[i] = ex

    if N != 1:
        ans[int(N)] = 1
    return ans

N = int(input())
max_x = 0
max_n = 0

if N == 1:
    print((1))
    return

for i in range(N+1):
    num = fact(i)
    num = num.get(2, 0)
    if num > max_n:
        max_x = i
        max_n = num

print(max_x)


# B - Break Number
def main():
    n = int(input())

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

if __name__ ==  "__main__":
    main()

N = int(input())
result = 0
for i in range(7):
  if N >= 2**i:
    result = 2**i
  else:
    None
print(result)


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


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

print(ans//2)

n = int(input())
a = n
m = 0
for i in range(n+1):
    j = 1
    for h in range(i+1):
        if i%(2**j) != 0:
            if m < j-1:
                m = j-1
                a = i
            break
        j += 1
print(a)

N = int(input())

count_max = -1
OK = True

for i in range(N):
    count = 0
    a = N - i
    while a % 2 == 0:
        a = a // 2
        count += 1
        if count_max < count:
            count_max = count
    else:
        continue
if 2 ** count_max == 0.5:
    print(1)
else:
    print(2 ** count_max)

n = int(input())
 
k = 0
while 1:
    if 2 ** k > n:
        break
 
    ans = 2 ** k
    k += 1
 
print(ans)

import sys
sys.setrecursionlimit(250000)

def main():
    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(n)
main()



#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)


# if b > c * 2 :
    #     b_price = c
    #
    # input_array_list = []
    #
    # while True:
    #     input_array = input().split()
    #     if input_array[0] == "0" and input_array[1] == "0":
    #         break
    #     else:
    #         input_array_list.append(input_array)
    #
    # for item in input_array_list:
    #     n = int(item[0])
    #     k_sum = int(item[1])
    #
    #     count = 0
    #     for i in range(1,n + 1- 2):
    #         for j in range(i+1, n + 1 - 1):
    #             for k in range (j+1, n+ 1):
    #                 if i + j + k == k_sum :
    #                     count = count + 1
    #     print(count)

    #
    # for item in input_array_list:
    #     if item[1] == "+":
    #         print(str(int(item[0])+int(item[2])))
    #     elif item[1] =="-":
    #         print(str(int(item[0])-int(item[2])))
    #     elif item[1] == "/":
    #         print(str(int(item[0])//int(item[2])))
    #     elif item[1] == "*":
    #         print(str(int(item[0])*int(item[2])))
    #

# import sympy as sp

# input_list = []
# a,b,c = map(int, input().split())
# divisors = sp.divisors(c)
#
# count = 0
#
# for divisor in divisors:
#     if a <= divisor and divisor <= b:
#         count = count + 1
# print(count)
#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)
#
# for pair_int in input_list:
#     if pair_int[0] <= pair_int[1]:
#         print("{} {}".format(pair_int[0], pair_int[1]))
#     else:
#         print("{} {}".format(pair_int[1], pair_int[0]))

#for i in range(10000):
#    print("Hello World")
#a = input().split()
#a_int = [int(s) for s in a]
#a_sorted = sorted(a_int)
#print(' '.join(map(str, a_sorted)))


N = int(input())
i = 0
while True:
    if 2**i > N:
        print(2**(i-1))
        return
    i += 1

import math as mt
n=int(input())
print(2**int(mt.log2(n)))

from itertools import count
n = int(input())
for i in count(0):
    if n < 2**(i+1):
        print(2**i)
        break

import math
n = int(input())
ans = pow(2,int(math.log(n)/math.log(2)))
print(ans)

N = int(input())

cnt = 0

while 2 ** cnt <= N:
    cnt+=1

cnt-=1

print(2**cnt)

n = int(input())


class Solution:
    def __init__(self, n):
        self.n = n

    @staticmethod
    def answer():
        ans = 1
        current_zero_count = 0
        for i in range(1, n + 1):
            target_zero_count = list(map(int, bin(i)[2:])).count(0)
            if n == 1:
                break
            else:
                if target_zero_count > current_zero_count:
                    current_zero_count = target_zero_count
                    ans = i
        print(ans)


conditions = Solution(n)
conditions.answer()

n = int(input())
ans = 1
current_zero_count = 0
for i in range(1, n + 1):
    target_zero_count = list(map(int, bin(i)[2:])).count(0)
    if n == 1:
        break
    else:
        if target_zero_count > current_zero_count:
            current_zero_count = target_zero_count
            ans = i
print(ans)

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)

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


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)

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

N = int(input())
result = 0
num = 1
for i in range(7):
  if N >= num:
    result = num
  else:
    None
  num *= 2
print(result)

n = int(input())
max_count = 0
ans = 1
for i in range(1, n + 1):
  num = i
  count = 0
  while num % 2 == 0:
    num //= 2
    count += 1
  if count > max_count:
    ans = i
    max_count = count
print(ans)

N = int(input())
print((max(2 ** i if 2 ** i <= N else 0 for i in range(10))))



def dev2(a):
    ans = 0 
    while a%2==0:
        ans+=1
        a/=2
        if a == 0 : break
    return ans

n = int(input())
ans = 0 
ans_num = 0
for i in range(1,n+1):
    if ans < dev2(i):
        ans_num = i
        ans = dev2(i)    
print((1 if n==1 else ans_num))


N = int(input())

ans = 1
prev = 0
for i in range(1, N + 1):
    count = 0
    tmp = i
    while i % 2 == 0 and 1 < i:
        count += 1
        i /= 2
    if prev < count:
        prev = count
        ans = tmp

print(ans)


print(2 ** (len(bin(int(input()))) - 3))

N=int(input())
def rec(n):
    if n%2==0: return rec(n/2)+1
    else: return 0
m,c=0,1
for i in range(1,N+1):
    if m < rec(i):
        m=rec(i)
        c=i
print(c)

def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  n = int(input())
  cnt = 1
  while n >= cnt:
    ans = cnt
    cnt *= 2
  print(ans)
def __starting_point():
  main()
__starting_point()