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



Sample input:
7


Sample output:
4

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(2 ** (i - 1))

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc068/tasks/abc068_b
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
N = int(input())
X = 1
while(N>=X):
  X = X<<1
print(X>>1)

Submission status: Accepted

Solution code:
N = int(input())

count = 0

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

print(2**count)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC068B - Break Number
n = int(input())
count = 0
while n > 1:
    n //= 2
    count += 1
print(2 ** count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:


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

def div_2(x, memo):
    # 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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n = int(input())
ans = [1, 2, 4, 8, 16, 32, 64]

print(max([i for i in ans if n-i >= 0]))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc068/tasks/abc068_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    ans = 0
    count = -1
    for i in range(1, N+1):
        c = 0
        v = i
        while v % 2 == 0:
            c += 1
            v //= 2
        if c > count:
            count = c
            ans = i

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(N, 0, -1):
	a = bin(i)
	if a[2] == "1":
		if len(a) == 3:
			print(1)
			exit()
		elif not "1" in a[3:]:
			print(i)
			exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N = int(input())
c = 0
while True:
  if N // 2 > 0:
    c += 1
    N = N // 2
  else:
    break
print(pow(2, c))

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 1
cnt_ans = 0

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math


N = int(input())

ans = 1
cnt_ans = 0
for i in range(1,N+1):
    tmp = i
    cnt = 0
    while tmp % 2 == 0:
        tmp //= 2
        cnt += 1
    if cnt > cnt_ans:
        ans = i
        cnt_ans = cnt

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans, Max = 1, 0
for i in range(1, N+1):
    ct = 0
    tmp = i
    while tmp % 2 == 0:
        tmp //= 2
        ct += 1
    if ct > Max:
        Max = ct
        ans = i

print(ans)

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-

x=int(input())

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

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    cnt = 1
    ans = 1
    for i in range(1,N):        
        if(cnt*2 > N):
            ans = cnt
            break
        else:
            cnt *= 2
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def div(x):
    while x!=1:
        if x%2:
            return False
        x//=2
    return True
for i in range(int(input()),0,-1):
    if div(i):
        print(i)
        break

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
check = 0
ans = 1
for i in range(1, N+1):
    cnt = 0
    j = i
    while j%2 == 0:
        cnt += 1
        j //= 2
    if cnt > check:
        ans = i
        check = cnt

print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    i = 1
    while i * 2 <= n:
        i *= 2
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
p = 10
res = 0

for i in range(p):
  if 2** i <= N:
    res = i
  else:
    break
    
print(2**res)

Submission status: Accepted

Solution code:
import math

n = int(input())
print(2 ** math.floor(math.log2(n)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,x=int(input()),1
while n>=x:x*=2
print(x//2)

Submission status: Accepted

Solution code:
n=int(input())
s=[2**p for p in range(7)]
print(max([c for c in s if c<=n]))

Submission status: Accepted

Solution code:
n = int(input())

score = {}
for i in range(1, n+1):
    c = 0
    i_ = i
    while(1):
        if i_ % 2 == 0:
            i_ /= 2
            c += 1
        else:
            break
    score[i] = c 

ans = max(score.items(), key=lambda x:x[1])[0]    
        
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
P=0
for i in range(8) :
  if 2**i <= N : 
    P=2**i 
  else :
    break
print(P)

Submission status: Accepted

Solution code:
N = int(input())

max_n = 0
max_times = -1
for i in range(1, N + 1):
    times = 0
    original_i = i
    while i % 2 == 0:
        i //= 2
        times += 1
    if times >= max_times:
        max_n = original_i
        max_times = times
print(max_n)

Submission status: Accepted

Solution code:
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
else:
  print(ans)

Submission status: Accepted

Solution code:
N=int(input())
a=b=c=0
for i in range(N+1):
    if i!=0:
        j=i
        while i%2==0:
            a=a+1
            i=int(i/2)
        if a>b:
            b=a
            c=int(j)
        a=0
if c==0:
    print(1)
else:
    print(c)

Submission status: Accepted

Solution code:
N = int(input())

def func(N):
	for i in range(7, 0, -1):
		if 2**i <= N:
			print(2 ** i)
			break
	else:
		print(N)

#for i in range(1, 100 + 1):
#	print(i, ":", end="")
#	func(i)

func(N)

Submission status: Accepted

Solution code:
n=int(input())
i=0
m=[]
while 2**i<=n:
  if 2**i<=n:
    m.append(2**i)
    i=i+1
print(m[-1])

Submission status: Accepted

Solution code:
n=int(input())
if n<2**1:
  print(1)
elif n<2**2:
  print(2)
elif n<2**3:
  print(4)
elif n<2**4:
  print(8)
elif n<2**5:
  print(16)
elif n<2**6:
  print(32)
elif n<2**7:
  print(64)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(7):
    if 2**i<=n<2**(i+1):
        print(2**i)
        break

Submission status: Accepted

Solution code:
n = int(input())
two = 2
while n >= two:
	two = two*2
print(two//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
flag = True
ans = 1
while flag:
    ans = ans * 2
    if ans > N:
        flag = False
print(ans//2)

Submission status: Accepted

Solution code:
N=int(input())
print([2**i for i in range(8) if 2**i<=N][-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
max_counter = 0
ans = 1

for i in range(N+1):
    counter = 0
    ans_i = i
    for j in range(7):
        if i % 2 == 0:
            counter += 1
            i = i / 2
        else:
            if counter > max_counter:
                 max_counter = counter
                 ans = ans_i
            break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
i = 1
while 2 ** i <= N:
    ans = 2 ** i
    i += 1
if N == 1:
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
nums = []
anss = []
for i in range(1, int(input())+1):
    count = 0
    while i%2 == 0:
        i //= 2
        count += 1
    anss.append(count)
print(anss.index(max(anss))+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = [2 ** i for i in range(1, 7)]
ans = 1
for a in A:
  if (n < a):
    break
  ans = a
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = [-1000] + [0] * n
for i in range(1, n + 1):
  j = i
  while (j % 2 == 0):
    ans[i] += 1
    j /= 2
print(ans.index(max(ans)))

Submission status: Accepted

Solution code:
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n = ni()

for i in range(n, -1, -1):
    if bin(i)[2:].count('1') == 1:
        print(i)
        exit()

Submission status: Accepted

Solution code:
N = int(input())
n = 1
while 1:
	if n>N:
		print(n//2)
		break
	n = n*2

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def get(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x = x/2
    return cnt
n = int(input())
at = 1
ans = 0
for i in range(1,n+1):
    a = get(i)
    if ans < a:
        ans = a
        at = i
print(at)

Submission status: Accepted

Solution code:
N = int(input())
print(2 ** (len(bin(N)) - 3))

Submission status: Accepted

Solution code:
n = int(raw_input())
count0 = 0
ans = 1
for i in range(1, n+1):
	count = 0
	j = i
	while j % 2 == 0:
		j = j / 2
		count += 1
		if count > count0:
			ans = i
			count0 = count
print ans

Submission status: Accepted

Solution code:
a = int(input())
max_count = 0
max_number = 1

for i in range(1,a+1):
    count = 0
    hold = i
    while i%2 == 0:
        count += 1
        i //= 2
    if count > max_count:
        max_count = count
        max_number = hold
        
print(max_number)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
l=[i for i in range(1,n+1)]
lst=[]
for i in range(n):
  a=0
  p=l[i]
  q=p
  while q%2==0:
    a+=1
    q=q//2
  lst.append((a,p))
lst.sort(reverse=True)
print(lst[0][1])

Submission status: Accepted

Solution code:
N = int(input())

S = [1, 2, 4, 8, 16, 32, 64]
ans = -1
for s in S:
    if s <= N:
        ans = s

print(ans)

Submission status: Accepted

Solution code:

n = int(input())

x = [2 ** i for i in range(7)]

import bisect

b = bisect.bisect_right(x, n)

print(x[b-1])

Submission status: Accepted

Solution code:
N = int(input())
A = [2,4,8,16,32,64]
ans = 1
for a in A:
  if a <= N:
    ans = a
print(ans)

Submission status: Accepted

Solution code:
#68
n = int(input())
ans = 1
while(n>=ans):
    ans = ans*2
print(ans//2)

Submission status: Accepted

Solution code:
N = int(input())
count = 0
ans = 1
for i in range(1,N+1):
    tmp_count = 0
    tmp_i = i
    while(tmp_i%2==0):
        tmp_count+=1
        tmp_i /= 2
    if count < tmp_count:
        count = tmp_count
        ans = i
print(ans)

Submission status: Accepted

Solution code:
import sys

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

if N in [1, 2, 4, 8, 16, 32, 64]:
    print(N)
else:
    sorted_list = sorted([1, 2, 4, 8, 16, 32, 64, N])[::-1]
    min_index = sorted_list[sorted_list.index(N) + 1]
    print(min_index)

Submission status: Accepted

Solution code:
m = int(input())
a = 1
for c in range(7):
  if (2 ** c) > m:
    break
  a = (2 ** c)
 
print(a)

Submission status: Accepted

Solution code:
n=int(input())
import math
ans=2**int(math.log(n,2))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
x = 1
while(True):
    if x * 2 > N:
        break
    else:
        x *= 2
print(x)

Submission status: Accepted

Solution code:
N = int(input())

max_num = 1
max_cnt = 0
for n in range(1, N+1):
    cnt = 0
    tmp_n = n
    while True:
        if tmp_n % 2 == 0:
            cnt += 1
            tmp_n /= 2
        else:
            if cnt > max_cnt:
                max_num = n
                max_cnt = cnt
            break

print(max_num)

Submission status: Accepted

Solution code:
N = int(input())

mx = 0
for _ in range(N):
    num = 2**_
    if num <= N and mx < num:
        mx = num
print(mx)

Submission status: Accepted

Solution code:
n = int(input())
a = 1
while a <= n:
    a_ = a * 2
    if a_ > n:
        break
    else:
        a = a_
print(a)

Submission status: Accepted

Solution code:
N=int(input())
num = [1,2,4,8,16,32,64]
if N>=64:
  print(64)
else:
  for i in range(len(num)):
    if num[i]>N:
      print(num[i-1])
      break

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N+1):
  a = i
  cnt = 0
  while a > 1:
    if a % 2 == 1:
      break
    else:
      a  = a//2
      cnt += 1
  ans = max(2**cnt,ans)

print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N = int(input())

max_count = 0
for i in range(1, N+1):
  n = i
  count = 0
  while n > 0 and n % 2 == 0:
    n = n//2
    count += 1
  if count == max(max_count, count):
    res = i
    max_count = count
print(res)

Submission status: Accepted

Solution code:
N = int(input())

max_count = 0
for i in range(1, N + 1):
    n = i
    count = 0
    while n > 0 and n % 2 == 0:
        n = n // 2
        count += 1
    if count == max(max_count, count):
        res = i
        max_count = count

print(res)

Submission status: Accepted

Solution code:
N=int(input())

tmp=0
for l in range(1,N+1):
    cnt=0
    while l%2==0:
        l/=2 
        cnt+=1

    #ansとcntの小さい方に更新
    tmp=max(cnt, tmp)
    ans=2**tmp

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

maximum = N
number = 0
for i in range(1,N+1):
  for j in range(1,N+1):
    if i%(2**j) != 0:
      break
  if j-1 > number:
    number = j-1
    maximum = i

print(maximum)

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())

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

    return ans


if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
print(2 ** math.floor(math.log2(n)))

Submission status: Accepted

Solution code:
N=int(input())
a=1
for i in range(7):
    if a*2 > N:
        break
    a*=2
print(a)

Submission status: Accepted

Solution code:
N = int(input())

best = 1
best_count = 0
for n in range(1, N+1):
    i = n
    count = 0
    while True:
        q, mod = divmod(i, 2)
        if mod == 0:
            i = q
            count += 1
        else:
            break
    if count > best_count:
        best = n
        best_count = count

print(best)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def count_of_divide_2(n):
    ret = 0
    while n % 2 == 0:
        n /= 2
        ret += 1
    return ret


n = int(input())
ans = 1
for i in range(1, n+1):
    if count_of_divide_2(ans) < count_of_divide_2(i):
        ans = i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
m = 1

while m <= n:
    m *= 2
print(m//2)

Submission status: Accepted

Solution code:
N = int(input())
ans = [2**i for i in range(0,7) if 2**i <= N]
print(ans[-1])

Submission status: Accepted

Solution code:
def break_number(N: int)->int:
    freq = [0] * (N+1)
    freq[0] = -float('inf')
    d = 2
    while d <= N:
        i = d
        while i <= N:
            freq[i] += 1
            i += d
        d <<= 1

    return freq.index(max(freq))


if __name__ == "__main__":
    N = int(input())
    ans = break_number(N)
    print(ans)

Submission status: Accepted

Solution code:
def break_number(N: int)->int:
    if N == 1:
        return 1

    freq = [0] * (N+1)
    d = 2
    while d <= N:
        i = d
        while i <= N:
            freq[i] += 1
            i += d
        d <<= 1

    return freq.index(max(freq))


if __name__ == "__main__":
    N = int(input())
    ans = break_number(N)
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
i=0
while 2**i<N:
  i += 1
  
if 2**i ==N:
  a =N
if 2**i>N:
  a =2**(i-1)

print(a)

Submission status: Accepted

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

while N >= a*2:
  a = a*2

print(a)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
escape = 0
for i in range(N, 0, -1):
	if i == 1:
		print(1)
		break
	ans = i
	while(1):
		if i%2 != 0:
			break
		if i%2 == 0 and i/2 != 1:
			i = i/2
		if i%2 == 0 and i/2 == 1:
			print(ans)
			escape = 1
			break
	if escape == 1:
		break

Submission status: Accepted

Solution code:
N = int(input())
max = 0
max_num = 1
for i in range(1,N+1):
    cnt = 0
    num = i
    while num % 2 == 0:  
        num /= 2
        cnt += 1
        if cnt > max:
            max = cnt
            max_num = i
print(max_num)

Submission status: Accepted

Solution code:
n=int(input())
cnt=1
X=[]
def two(n):
    cnt=0
    while n%2==0:
        n=n/2
        cnt+=1
    return cnt
res=0  
ans=n
for i in range(n,1,-1):
    if res<two(i):
        res=two(i)
        ans=i

print(ans)

Submission status: Accepted

Solution code:
# 067 B
N=int(input())
for i in range(0,7):
    ans =2**i
    if ans <= N and N< 2*ans:
        print(ans)
        break

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
from math import log2,floor;print(2**floor(log2(int(input()))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print(1)
    exit()
X = [2, 4, 8, 16, 32, 64, 128]
for i, x in enumerate(X):
    if N < x:
        print(X[i - 1])
        exit()

Submission status: Accepted

Solution code:
import math
N=int(input())
if N==1:
    ans=1
else:
    n1=math.log(N,2)
    n2=math.floor(n1)
    ans=2**n2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i=int(input())
for n in range(0,9):
  if 2**n<=i<2**(n+1):
    print(2**n)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
two=[1,2,4,8,16,32,64]
two.reverse()
n=int(input())
for i in range(7):
  if two[i]<=n:
    print(two[i])
    exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a = int(input())
ans = 1
while ans <= a:
  ans *= 2
print(ans // 2)

Submission status: Accepted

Solution code:
n=int(input())
ans=1
for i in range(1,(n+1)):
  if (i//ans)%2 == 0:
    ans=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list_2 = []
for i in range(7):
    list_2.append(2 ** i)
    
ans = 1
for i in list_2:
    if i <= N:
        ans = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
print(2**(len(bin(n)[2:])-1))

Submission status: Accepted

Solution code:
n = int(input())
M = 0
ans = 1
for i in range(1, n + 1):
  t = i
  s = 0
  while t % 2 == 0:
    t /= 2
    s += 1
  if M < s:
    M = s
    ans = i
print(ans)