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())
res=[]
for i in range(0,N+1) :
  if N>=2**i :
    res.append(2**i)
print(res[-1])

Submission status: Accepted

Solution code:
n = int(input())

ans = 1
cnt = 0

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

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:
# B - Break Number
N = int(input())
print(2**(N.bit_length()-1))

Submission status: Accepted

Solution code:
N = int(input())
count = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())


N = I()
a = 1
while a <= N:
    if 2*a > N:
        print(a)
    a *= 2

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    s = {1, 2, 4, 8, 16, 32, 64}
    ans = 0

    for i in range(1, N + 1):
        if i in s:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

import math as m

x = m.log(N,2)
print(2**int(x))

Submission status: Accepted

Solution code:
N = int(input())
pi = 0
for n in range(1, N+1):
  i = 0
  dn = n
  while dn % 2 == 0:
    i += 1
    dn = dn / 2
    if dn % 2 == 1:
      break
  
  if i >= pi:
    result = n
    pi = i
  else:
    pass
  

print(result)

Submission status: Accepted

Solution code:
n = int(input())
for i in range(7):
  c = 2**i
  if c > n:
    c //= 2
    break
print(c)

Submission status: Accepted

Solution code:
n = int(input())


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
if n==1:
  print(1)
else:
  for i in range(9):
    a=2**i
    if  a>n:
      print(a//2)
      break

Submission status: Accepted

Solution code:
n = int(input())

maxdivisiontimes = -1
while n != 0:
    flag = True
    checkcounter = 0
    checkno = n
    while flag == True:
        if checkno % 2 == 0:
            checkcounter += 1
        checkno = checkno // 2 
        if checkno == 1 or checkno == 0:
            flag = False
    if maxdivisiontimes < checkcounter:
        maxdivisiontimes = checkcounter
        maxdivisionno = n
    n -= 1
print(maxdivisionno)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
  if 2**i <= N:
    ans = 2**i
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
even_count = [0 for i in range(n)]
for i in range(1,n+1):
  j = i
  count = 0
  while True:
    if i % 2 == 0:
      count += 1
      i = int(i / 2)
    else:
      break
  even_count[j-1] = count
print(np.argmax(even_count)+1)

Submission status: Accepted

Solution code:
N = int(input())

power = 1

while power <= N:
    power *= 2
    if power == N:
        print(power)
        exit()
    elif power > N:
        print(power // 2)
        exit()

Submission status: Accepted

Solution code:
n = int(input())
max_cnt = 0
max_num = 1

#1からnまでの数を調べる
for i in range(1, n + 1):
    count = 0
    num = i
    #iが2で割りきれるまで割る
    while i % 2 == 0 :
        count += 1
        i = i//2
    
    #割り切れる回数を更新
    if max_cnt < count :
        max_cnt = count
        max_num = num

print(max_num)

Submission status: Accepted

Solution code:
N = int(input())
cnt_max = 0

for i in range(N):
    num = i+1
    cnt = 0
    while True :
        if num % 2 == 0:
            cnt += 1
            num /= 2
        else:
            break
    if cnt_max < cnt:
        cnt_max = cnt

print(2**cnt_max)

Submission status: Accepted

Solution code:
# coding: utf-8

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

Submission status: Accepted

Solution code:
N = int(input())
result = []
for i in range(1, N+1):
    bin_i = bin(i)
    bin_i_c = bin_i.count("0")-1
    result.append(bin_i_c)
sorted_result = sorted(result, reverse = True)
print(2 ** sorted_result[0])

Submission status: Accepted

Solution code:
N = int(input())

L = [0] * 101
for i in range(1, 101):
    cnt = 0
    tmp = i
    while tmp % 2 == 0:
        cnt += 1
        tmp //= 2
    L[i] = cnt

print(L.index(max(L[1:N+1])) if N !=1 else 1)

Submission status: Accepted

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

for i in range(1, N + 1):
    cnt = 0
    num = i
    while True:
        if num % 2 == 0:
            cnt += 1
            num /= 2
        else:
            break
    if cnt_max < cnt:
        cnt_max = cnt
        ans = i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = []

for i in range(1001):
    l.append(2**i)

最大 = 0
for i in range(n+1):
    if i in l:
        最大 = i

print(最大)

Submission status: Accepted

Solution code:
def div_by_two(x, div_times):
	x = x / 2
	if x == int(x):
		div_times += 1
		div_times = div_by_two(x, div_times)
		
	return div_times
		

N = int(input())

ans = 1
max_div_times = 0
for i in range(1, N+1):
	div_times = div_by_two(i, 0)
	if div_times > max_div_times:
		max_div_times = div_times
		ans = i
		
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())
a=[]
for b in range(1,N+1,1):
  count=0
  while b%2 == 0:
    count+=1
    b/=2
  a.append(count)

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

Submission status: Accepted

Solution code:
"""Boot-camp-for-Beginners_Easy011_B_Collatz-Problem_29-August-2020.py"""
import numpy as np

#N = 100
N=int(input())
Division_2 = []
number=[]
for i in range(1, N+1):
    j = i
    count = 0
    while True:
        if j/2 != int(j/2):
            break
        j = j/2
        count += 1
    Division_2.append(count)
    number.append(i)
Division_2=np.array(Division_2)
print(number[np.argmax(Division_2)])
#print(Division_2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = []
for i in range(1, n + 1):
    x = i
    for j in range(100):
        if x % 2 == 0:
            x = int(x // 2)
            #ans.append(j)
        else:
            #ans.append(j)
            break
    ans.append(j)

#print(ans)
print(ans.index(max(ans)) + 1)

Submission status: Accepted

Solution code:
N = int(input())
if N <= 1:
  print(1)
  exit()

value = 1
result = 0
while N >= value:
  value *= 2
print(value // 2)

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


def main():
    n = int(input())
    ans = n
    max = 0
    for i in range(1, n + 1):
        c = len(bin(i)) - bin(i).rfind("1") - 1
        if max < c:
            max = c
            ans = i
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def main():
    N = int(input())
    nums = range(1, N + 1)
    while True:
        nums = [i // 2 if i % 2 == 0 else 0 for i in nums]
        if sum(nums) == 1:
            print([i + 1 for i in range(N) if nums[i] == 1][-1])
            break
        elif sum(nums) == 0:
            print(len(nums))
            break


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

N = int(input())

ans = 1
ma = 0
for i in range(1,N+1):
    if lo2(i)>ma:
        ans = i
        ma=lo2(i)

print(ans)

Submission status: Accepted

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

def counter(num):
    cnt = 0
    while True:
        if num % 2 == 0:
            num = int(num/2)
            cnt += 1
        else:
            break

    return cnt



N = int(input())

max_cnt = 0
max_num = num = N
for num in range(N,0,-1):
    cnt = counter(num)
    if cnt > max_cnt:
        max_cnt = cnt
        max_num = num   

print(max_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

exp_2_list = []
for i in range(100):
  exp_2 = 2 ** i
  if exp_2 > 100:
    break
  exp_2_list.append(exp_2)

answer = 1
for exp_2 in sorted(exp_2_list, reverse=True):
  if exp_2 <= N:
    answer = exp_2
    break

print(answer)

Submission status: Accepted

Solution code:
def main():
    n = int(input())

    power = 0

    while 2 ** power <= n:
        power += 1

    print(2 ** (power-1))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a=int(input())
b=1
total2=0
for i in range(1,a+1):
    total=0
    a=i
    while True:
        if a%2==0:
            a=a/2
            total+=1
        else:
            if total2<total:
                total2=total
                b=i
            break
print(b)

Submission status: Accepted

Solution code:
N = int(input())
Ns = {}
for i in range(1, N + 1):
	num = i
	cnt = 0
	while num % 2 == 0:
		num //= 2
		cnt += 1
	Ns[i] = cnt
print(max(Ns, key=Ns.get))

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:
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    if n<2:
        print(n)
        return
    x = 2
    while x*2<=n:
        x *= 2
    print(x)
    return

if __name__=='__main__':
    n = I()
    solve()

Submission status: Accepted

Solution code:
import sys
n = int(input())
for i in range(n):
  m = n-i
  for j in range(0,7):
    if 2**j == m:
      print(m)
      sys.exit()

Submission status: Accepted

Solution code:
n = int(input())
a = 64
while True:
    if a <= n:
        print(a)
        exit()
    elif n == 1:
        print(1)
        exit()
    a = a // 2

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(100):
    if 2**i<=n:
        continue
    else:
        print(2**(i-1))
        exit()

Submission status: Accepted

Solution code:
print(1<<len(bin(int(input())))-3)

Submission status: Accepted

Solution code:
N = int(input())
list2 = []

list1 =[int(i) for i in range(1,N+1)]
for i in range(N):
  list2.append([i, list1[i]])

for i in range(N):
  if len(list2) == 1:
    ans = list2[0][0]
    print(ans+1)  
    break
  
    
  for a in list2:
    
    if a[1] % 2 != 0:
      list2.remove(a)

  for j in range(len(list2)):
    list2[j][1] = list2[j][1]/2

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [0]*n
j = 0
for i in range(1, n+1):
    while True:
        if i%2!=0:
            break
        i=i//2
        if i==0:
            break
        else:
            a[j]+=1
    j+=1
maxv = max(a)
maxi = a.index(maxv)
print(maxi+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

m = -1
ans = None
for i in range(N):
    j = i+1
    sum = 0
    while True:
        if j%2 == 0:
            j //= 2
            sum+=1
        else:
            break
    if sum > m:
        m = sum
        ans = i+1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
mx = 0
ans = 1
for i in range(1, n+1):
    v = i
    count = 0
    while v//2 != 0 and v % 2 == 0:
        count += 1
        v = v//2
    if count >= mx:
        ans = i
    mx = max(mx, count)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ary = [2 ** n for n in range(7, 0, -1)]

    for i, a in enumerate(ary):
        if N < a:
            continue
        else:
            print(a)
            return
    print(N)


main()

Submission status: Accepted

Solution code:
N=int(input())

ans = 0
tmp = 1
while tmp*2 <= N:
    ans += 1
    tmp *= 2
print(tmp)

Submission status: Accepted

Solution code:
n=int(input())
m=0
p=1
for i in range(1,n+1):
    if(i%2==0):
        x=i
        c=0
        while(x%2==0):
            c+=1
            x//=2
        if(c>m):
            m=c
            p=i
print(p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
b = n.bit_length() - 1
ans = int('0b1'+'0'*b, 2)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
lis=[]
for i in range(1,N+1):
    for j in range(N):
        if i%(2**j)==0:
            lis.append(j)
print(2**max(lis))

Submission status: Accepted

Solution code:
import math
N=int(input())
a=[]
for i in range(1,N+1):
    if math.log2(i)%1==0:
        a.append(i)
print(a[len(a)-1])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans,result=0,0
for i in range(1,int(input())+1):
  count=0
  num=i
  while num%2==0:
    num//=2
    count+=1
  if ans < count:
    ans=count
    result=i
print(1 if not (ans and result) else result)

Submission status: Accepted

Solution code:
n = int(input())
l = []

for i in range(n+1):
    if 2**i <= n:
        l.append(2**i)
    
print(max(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
array = [0]*n

for i in range(1, n+1):
  count = 0
  num = i
  while num%2==0:
    count += 1
    num = int(num/2)
  array[i-1] = count
print(1+np.argmax(array))

Submission status: Accepted

Solution code:
N = int(input())
m = 1
d_cnt = 0
for i in range(1, N+1):
    num = i
    cnt = 0
    while True:
        if num % 2 == 0:
            num /= 2
            cnt += 1
        else:
            break
    if d_cnt < cnt:
        d_cnt = cnt
        m = int(i)
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

d={"num":1,"ans":1}
for i in range(1,n+1):
  if i%2==0:
    num=i
    ans=0
    while i%2==0:
      i=i/2
      ans+=1
    if ans>=d["ans"]:
      d["num"]=num
      d["ans"]=ans
    
print(d["num"])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
q=0
ans=1
for i in range(1,n+1):
    m=i
    p=0
    while(m%2==0):
        m//=2
        p+=1
    if q!=max(q,p):
        ans=i
        q=max(q,p)
print(ans)

Submission status: Accepted

Solution code:
N = int (input ())
x = 1
while x <= N:
  x = x*2
print (round (x/2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = 0
b = 0
for k, v in dic.items():
  if a < v:
    b = k
    a = v

if b == 0:
  print(1)
else:
  print(b)

Submission status: Accepted

Solution code:
def gusuuhantei(i):
    count = 0
    num = i
    while True:
        if num % 2 ==0 and not num == 0:
            num = num / 2
            count += 1
        else:
            break
    return count
N = int(input())
li = [-1]*(N+1)
for i in range(1, N+1):
    li[i] = gusuuhantei(i)
Maxcount = max(li)
index = li.index(Maxcount)
print(index)

Submission status: Accepted

Solution code:
def gusuuhantei(i):
    count = 0
    num = i
    while True:
        if num % 2 ==0 and not num == 0:
            num = num / 2
            count += 1
        else:
            break
    return count
N = int(input())
li = [0]*(N+1)
for i in range(N+1):
    li[i] = gusuuhantei(i)
Maxcount = max(li)
index = li.index(Maxcount)
if N == 1:
    print(1)
else: 
    print(index)

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())
a = 0
while 2**a <= n:
    a += 1 
print(2**(a-1))

Submission status: Accepted

Solution code:
n=int(input())
a=[2**i for i in range(6,-1,-1)]
for i in a:
    if n>=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())
n = 1
a = 0
while n <= N:
    n *= 2
    if n > N:
        break
    else:
        a += 1
ans = int(n / 2)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
x = 2
for i in range(100):
    if x**i > N:
        ans = x**(i-1)
        break
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())
if N==1:
    print(1)
else:
    k = 1
    while 2**k<=N:
        k += 1
    print(2**(k-1))

Submission status: Accepted

Solution code:
N = int(input())

x = 1
while True:
    if x * 2 > N:
        break
    x *= 2

print(x)

Submission status: Accepted

Solution code:
n=int(input())
max_n=1
max_c=0

for i in range(n+1):
  c=0
  num=i
  while True:
    if num/2==0:
      break
      
    if num%2==0:
      c+=1
      num=num/2     
    else:
      break
      
  if c > max_c:
    max_c=c
    max_n=i
    
print(max_n)

Submission status: Accepted

Solution code:
N = int(input())
for n in range(7):
    if 2 ** n <= N:
        ans = 2 ** n
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

Ns = [i for i in range(1,N+1)]

counts = []
for N in Ns:
    count = 0
    while N % 2 == 0:
        N //= 2
        count += 1
    counts.append(count)

print(Ns[np.argmax(counts)])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())
count=[]
for n in range(1,N+1):
    count_n=0
    while n%2==0:
        n=n/2
        count_n+=1
    count.append(count_n)

answer=count.index(max(count))+1
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
ans = 1
maxnum_devide = 0
for num in range(2, n+1):
  target = num
  num_devide = 0
  while target % 2 == 0:
    target /= 2
    num_devide += 1
  if num_devide > maxnum_devide:
    ans = num
    maxnum_devide = num_devide
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

for i in range(8):
    if 2**i> n:
        break

print(2**(i-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
ma=-1
for i in range(1,int(input())+1):
  cnt=0
  x=i
  while x&1==0:
    x//=2
    cnt+=1
  if ma<cnt:
    ma=cnt
    ans=i
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())

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:
#
# abc068 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """32"""
        output = """32"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """100"""
        output = """64"""
        self.assertIO(input, output)


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


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
#
# abc068 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """32"""
        output = """32"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """100"""
        output = """64"""
        self.assertIO(input, output)


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


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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())
for i in range(10):
    if 2**i>n:
        ans=i-1
        break
print(2**ans)

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
for i in range(1,N+1):
    if len(bin(i))-bin(i).rfind("1") >= cnt:
        cnt += 1
        ans = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans_list = [1, 2, 4, 8, 16, 32, 64]

for n in ans_list:
    if (n <= N):
        ans = n

print(ans)

Submission status: Accepted

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

print(2**n)

Submission status: Accepted

Solution code:
def divide_by_2(num):
	cnt = 0		

	while True:
		if num % 2 != 0:
			break
		num /= 2
		cnt += 1
	
	return cnt


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

	lst = [-1] * (N + 1)

	for num in range(1, N + 1):
		cnt = divide_by_2(num)
		lst[num] = cnt

	print(lst.index(max(lst)))


  
if __name__ == "__main__":
  	main()

Submission status: Accepted

Solution code:
def divide_by_2(num):
	cnt = 0		

	while True:
		if num % 2 != 0:
			break
		num /= 2
		cnt += 1
	
	return cnt



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

	max_cnt = -1
	ans = 0

	for num in range(1, N + 1):
		cnt = divide_by_2(num)

		if max_cnt < cnt:
			max_cnt = cnt
			ans = num

	print(ans)


  
if __name__ == "__main__":
  	main()

Submission status: Accepted

Solution code:
N=int(input())
if N==1:
  print(1)
  exit()
L=[1,2,4,8,16,32,64,128]
for i in range(7):
  if L[i+1]>N:
    print(L[i])
    exit()

Submission status: Accepted

Solution code:
n = int(input())
num = [1,2,4,8,16,32,64,101]
for i in range(7):
    if num[i] <= n < num[i+1]:
        print(num[i])

Submission status: Accepted

Solution code:
N = int(input())
AA = [2,4,8,16,32,64]

if N >=64:
    print(64)

elif N in AA:
    print(N)

else:
    for i in range(6):
        num = AA[i]
        if num < N:
            pass

        elif num > N:
            print(round(num/2))
            break

Submission status: Accepted

Solution code:
import math;print(int(2**(math.log2(int(input()))//1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
print 2 ** int(math.floor(math.log(int(raw_input()),2)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
r = math.floor(math.log2(n))

print(2 ** r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
best = 0
for i in range(2, n+1, 2):
	c = 0
	j = i
	while(j % 2 == 0):
		j = j // 2
		c += 1
	best = max(best, c)
print(2 ** best)

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:
import math
print(2**math.floor(math.log2(int(input()))))