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:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

N = int(input())

maxi_num = 0
ans = 1

def div_count(x):
    num = 0
    while True:
        if x % 2 == 0:
            x /= 2
            num += 1
        else:
            break
    
    return num

for i in range(1, N+1):
    count = div_count(i)
    if maxi_num < count:
        maxi_num = count
        ans = i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print(1)
else:
    m = 0
    ans = 0
    for n in range(1, N + 1):
        t = 0
        i = n
        while(i % 2 == 0):
            i /= 2
            t += 1
        if t > m:
            m = t
            ans = n
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(1 << int(input()).bit_length() - 1)

Submission status: Accepted

Solution code:
N = int(input())
for i in range(8):
    if 1 << i <= N < 1 << (i + 1):
        print(1 << i)

Submission status: Accepted

Solution code:
N=int(input())

i=6
while i>-1:
  if N >= 2**i:
    print(2**i)
    break
  i-=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
c = []
d = []
if(n == 1):
  print(int(n))
  exit()

for i in range(1,n+1):
  x = 0
  j = 0
  k = 0
  if(i%2 == 0):
    x = i
    while True:
      x = int(x/2)
      k = k + 1
      if(x == 0 or x%2 == 1):
        c.append(k)
        d.append(i)
        break
  else:
    continue

c_m = max(c)
u = c.index(c_m)
print(d[u])

Submission status: Accepted

Solution code:
i = int(input())
cnt =0
while i >=2:
  i /= 2
  cnt +=1
print(2**cnt if cnt > 0 else i)

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())
  
n = i()
ans = 0
cnt = 0
def f(a):
	cnt = 0
	while a%2 == 0:
		a //= 2
		cnt += 1
	return cnt
for i in range(1,n+1):
	if f(i) >= cnt:
		cnt = f(i)
		ans = i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = [int(x) for x in range(1,n+1)]
B = [0]*n

for i in range(n):
    while A[i] % 2 == 0:
        A[i] = A[i]//2
        B[i] += 1
        
ind = B.index(max(B))
tmp = [int(x) for x in range(1,n+1)]
print(tmp[ind])

Submission status: Accepted

Solution code:
n = int(input())
list = [2**i for i in range(7)]

ans = 1

for k in list:
  if k <= n:
    ans = k
    if ans == 64:
      print(ans)
      break
    else:
      continue
  else:
    print(ans)
    break

Submission status: Accepted

Solution code:
n = int(input())
ans = 1
while ans<=(n/2):
    ans = ans*2
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:
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:
def main():
	N = int(input())
	binary_list = [1,2,4,8,16,32,64]
	diff_n2binary = []
	for binary in binary_list:
		if binary <= N:
			diff_n2binary.append(abs(N - binary))
	print(binary_list[ diff_n2binary.index( min( diff_n2binary ) ) ] )

if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(7,-1,-1):
  if pow(2,i) <= n:
    print(pow(2,i))
    exit()

Submission status: Accepted

Solution code:
n = int(input())
c = 0
while(True):
    if(1<<c > n):
        c -= 1
        break
    else:
        c += 1
print(1<<c)

Submission status: Accepted

Solution code:
N = int(input())
result = 1
count = 0
for i in range(1, N + 1):
  a = i
  n = 0
  while a % 2 == 0:
    a /= 2
    n += 1
  if  n > count:
    result = i
    count = n
print(result)

Submission status: Accepted

Solution code:
import sys
N = int(input())
c = 0
a = 1
while 2 ** a < 100:
    if N < 2 ** a:
        print(2 ** (a - 1))
        sys.exit()
    a += 1
print(2 ** (a - 1))

Submission status: Accepted

Solution code:
def div2_count(x, n):
    if x % 2 == 1:
        return n
    else:
        return div2_count(x // 2, n+1)


N = int(input())

ans = [0, 0]
for i in range(1, N+1):
    y = div2_count(i, 0)
    if ans[1] <= y:
        ans = [i, y]

print(ans[0])

Submission status: Accepted

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

print(2 ** int(math.log(n, 2)))

Submission status: Accepted

Solution code:
N = int(input())

res = 1
maxi = 0
for i in range(1, N + 1):
    if i % 2 == 0:
        tmp = i
        cnt = 0
        while tmp % 2 == 0:
            cnt += 1
            tmp //= 2
        if maxi < cnt:
            res = i
            maxi = cnt

print(res)

Submission status: Accepted

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

while i <= n:
    i *= 2

print(i//2)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
mcnt = 0
ans = 1
temp = 0

for i in range(2, n + 1):
    temp = i
    while i%2 == 0:
        i //= 2
        cnt += 1
    if cnt > mcnt:
        mcnt = cnt
        ans = temp
    cnt = 0

print(ans)

Submission status: Accepted

Solution code:
A = [2**x for x in range(7)]
N = int(input())
for i in A:
  if i <= N:
    ans = i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 1
cnt = 0
for i in range(1, n+1):
    t = 0
    a = i
    while a // 2 != 0:
        a = a // 2
        t += 1
    if cnt < t:
        ans = i
        cnt = t
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

if n < 2:
    print(n)
elif 2 <= n < 4:
    print(2)
elif 4 <= n < 8:
    print(4)
elif 8 <= n < 16:
    print(8)
elif 16 <= n < 32:
    print(16)
elif 32 <= n < 64:
    print(32)
elif 64 <= n:
    print(64)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC068 B

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
tmp = 0

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

print(2**(cnt-1))

Submission status: Accepted

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

    i = 0
    ans = 1
    while 2**i < n:
        i += 1
    if 2**i == n:
        ans = 2**i
    else:
        ans = 2**(i-1)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
num = 0
ans = 0
cnt = 0
for i in range(1, n + 1):
    if i == 1:
        num = 1
        continue
    v = i
    while True:
        if v % 2 == 0:
            v = v // 2
            cnt +=1
        else:
            break
    if cnt > ans:
        num = i
        ans = cnt
    cnt = 0
print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
n = iin()
a = [1,2,4,8,16,32,64,128]
for i in range(7):
    if n >= a[i]:
        if n < a[i + 1]:
            print(a[i])
            break

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def div2count(n):
  cnt = 0
  while n % 2 == 0:
    cnt += 1
    n = n / 2
  return cnt

N = I()

ans = 1
ans_cnt = 0

for n in range(1,N+1):
  cnt = div2count(n)
  if ans_cnt < cnt:
    ans_cnt = cnt
    ans = n
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
results = 0
number = 0
for i in range(n + 1):
    if i == 0:
        continue
    if i == 1:
        number = 1
        continue
    count = 0
    v = i

    while v % 2 == 0:
        count += 1
        v = v / 2
    if results < count:
        results = count
        number = i
    continue
print(number)

Submission status: Accepted

Solution code:
N = int(input())
max_num = N
max_count = 0
for i in range(1,N+1):
    if i%2 != 0:
        continue
    j = i
    count = 0
    while j%2 == 0:
        count += 1
        j //= 2
    if max_count < count:
        max_count = count
        max_num = i
print(max_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for i in range(1, n+1):
    stop = True
    c = 0
    while stop :
        if i % 2 == 0:
            c += 1
            i = i/2
        else:
            stop = False
    if c >= count :
        count = c
print(2**count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
list = [64,32,16,8,4,2]
O = int(input())
if O == 1:
    print(1)
    exit()

for num in list:
    if O >= num:
        print(num)
        break

Submission status: Accepted

Solution code:
N = int(input())

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

count_dic = {}
for i in range(N+1):
    i_tmp = i
    count = 0
    while True:
        if i == 0:
            break
        elif i_tmp % 2 == 0:
            i_tmp = i_tmp / 2
            count += 1
        else:
            break
    count_dic[i] = count
print(max(count_dic, key=count_dic.get))

Submission status: Accepted

Solution code:
N = int(input())
li = []
for i in range(10):
    li.append(2**i)
ans = []
for j in li:
    if j <=N:
        ans.append(j)
print(max(ans))

Submission status: Accepted

Solution code:
n = int(input())

result = 1

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
s = 0
for i in range(1, n + 1):
    sub = 0
    g = i
    while g >= 2:
        sub += 1
        g = g // 2
    if s < sub:
        ans = i
        s = sub

print(max(ans,1))

Submission status: Accepted

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

if n == 1:
    print(1)
else:
    for i in b:
        if i > n:
            print(b[b.index(i)-1])
            break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    idx = -1
    cnt = -1
    for i in range(1,n+1):
        tmp = (bin(i)[2:])[::-1].find('1')
        if tmp > cnt:
            cnt = tmp
            idx = i
    print(idx)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

List = []
for x in range(1,N+1):
  s = 0
  while x % 2 == 0:
    s += 1
    x = x//2
  List.append(s)

t = max(List)
print(2**t)

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:
n = int(input())
a_list = [64,32,16,8,4,2,1]
for num in a_list:
  if n >= num:
    print(num)
    break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

def t(n):
    div = n
    cnt = 0
    while True:
        div, mod = divmod(div, 2)
        if mod == 0:
            cnt += 1
        else:
            return cnt

ans = 1
maxt = 0
for i in range(1, n+1):
    tt = t(i)
    if maxt < tt:
        maxt = tt
        ans = i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
answer_list = [0 for i in range(n)]
answer_count = [0 for i in range(n)]

for i in range(0,n):
    answer_list[i]=i+1
    while True:
        if answer_list[i]%2==0:
            answer_list[i]=answer_list[i]/2
            answer_count[i] +=1
        else:
            break
max_count = max(answer_count)
print(answer_count.index(max_count)+1)

Submission status: Accepted

Solution code:
n = int(input())

num = list(range(1, n+1))
num2 = list(range(1, n+1))
count = [0]*n

judge = 0

while True:
    for a in range(0, n):
        if num[a] % 2 == 0:
            judge += 1
            num[a] /= 2
            count[a] += 1
    if judge == 0:
        break
    judge = 0

mx = max(count)

for a in range(0, n):
    if count[a] == mx:
        ans = num2[a]
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

#なお、任意の整数 M に対して M の −2 進数表現が一意に定まることが証明できます。
#2桁ごとに見るとよかった（もう実験したよ）
def resolve():
    N=bin(int(input())) 
    #print(N)
    print(2**(len(N)-3))
#%%submit!
resolve()

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())
arr = [i for i in range(1,n+1)]
counter = 0
while len(arr) > 1:
  counter += 1
  i = 0
  while i < len(arr):
    if arr[i] % 2 != 0:
      arr.pop(i)
    else:
      arr[i] //= 2
      i += 1
print(arr[0] * (2**counter))

Submission status: Accepted

Solution code:
def actual(N):
    # 答え候補は 2の累乗 だけ(1<=N<=100なので、最大で64)
    answers = [2 ** i for i in range(6 + 1)]

    and_set = set(answers) & set(range(1, N + 1))

    return max(and_set)


N = int(input())

print(actual(N))

Submission status: Accepted

Solution code:

def actual(N):
    max_count = 0
    max_number = 1

    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_number = i
            max_count = count

    return max_number

  
N = int(input())

print(actual(N))

Submission status: Accepted

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
N = ri()
d = [2 ** i for i in range(10)][::-1]
for i in d:
    if i <= N:
        print(i)
        exit()

Submission status: Accepted

Solution code:
n = int(input())

ans = 2

while ans <= n:
    ans *= 2

print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

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

count = 0

while A != [] :
    A = A[1::2]
    count = count +1


print(2**(count-1))

Submission status: Accepted

Solution code:
n = int(input())

n2_list = [2, 4, 8, 16, 32, 64]

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())
tmp = []
for i in range(1,n+1):
	ans = 0
	while i % 2 ==  0:
		ans += 1
		i = int(i / 2)
	tmp.append(ans)
maxnum= max(tmp)
print(tmp.index(maxnum)+1)

Submission status: Accepted

Solution code:
n = int(input())
a = 0
b = 0
c = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N,-1,-1):
  if i == 64:
    print(i)
    break
  elif i == 32:
    print(i)
    break
  elif i == 16:
    print(i)
    break
  elif i == 8:
    print(i)
    break
  elif i == 4:
    print(i)
    break
  elif i == 2:
    print(i)
    break
  elif i == 1:
    print(1)

Submission status: Accepted

Solution code:
import math

N = int(input())

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

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())
for i in range(8):
  if 2**i>=N:
    ans=2**i
    an_ans=2**(i-1)
    if ans==N:
      print(ans)
    else:
      print(an_ans)
    exit()

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:
N = int(input())
Ans = [0] * N
def how_many_times_divisible(n):
    count = 0
    while n % 2 == 0:
        n = n // 2
        count += 1
    return count

flag = 0
ans = 1
for i in range(N):
    Ans[i] = how_many_times_divisible(i+1)
    if flag < Ans[i]:
        flag = Ans[i]
        ans = i+1



print(ans)

Submission status: Accepted

Solution code:
N = int(input())

x = 1
for i in range(10):
    if x*2 <= N:
        x *= 2
    else:
        break

print(x)

Submission status: Accepted

Solution code:
n = int(input())

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

if i > n:
    i //= 2

print(i)

Submission status: Accepted

Solution code:
N = int(input())

i = int(0)
best_times = int(0)
while i <= N:
    x = i
    answer_times = 0
    while x % 2 == 0 and x != 0:
        answer_times += 1
        x /= 2
    if best_times < answer_times:
        best_times = answer_times
    i += 1

answer = int(2 ** best_times)
print(answer)

Submission status: Accepted

Solution code:
import sys
n = int(input())
a = [2**i for i in range(0,7)]
for i in range(len(a)):
    if n == a[i]:
        print(a[i])
        sys.exit()
    elif n < a[i]:
        print(a[i-1])
        sys.exit()

print(64)

Submission status: Accepted

Solution code:
import math
print(int(math.pow(2, math.floor(math.log2(int(input()))))))

Submission status: Accepted

Solution code:
import sys

n = int(input())


#for i in reversed(range(1, n+1)):
#    if i % 2 == 0:
#        print(i)
#        sys.exit()

ans = 1
while ans < n:
    if ans * 2 <= n:    
        ans *= 2
    else:
        print(ans)
        sys.exit()

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 1

while ans<=n:
    if ans*2>n:
        print(ans)
        break
    else:
        ans *= 2

Submission status: Accepted

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

resolve()

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

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())
dict = {}
for i in range(1, N+1):
    n = float(i)
    cnt = 0
    while n/2>0.0:
        if n%2 == 0.0:
            cnt += 1
        n = n/2
    dict[i] = cnt

import numpy as np
print(list(dict.keys())[np.argmax(list(dict.values()))])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
ans =1
    
while  True:
    if ans*2 <= N:
        ans= ans*2
    else:
        break
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(input())


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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
# 4問目類題1
N = int(input())
for k in range(7):
    if 2**k <= N < 2**(k+1):
        print(2**k)

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
ans = 0
for i in range(1, N+1):
    tmp = i
    num = 0
    while tmp % 2 == 0:
        num += 1
        tmp = tmp // 2
    ans = max(ans, num)
print(2**ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
def niwari(x):
    count=0
    while x%2==0:
        x//=2
        count+=1
    return count
mx=0
ans=1
for i in range(1,n+1):
    if niwari(i)>mx:
        mx=niwari(i)
        ans=i
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input())

if N >= 64:
    N = 64
elif N >= 32:
    N = 32
elif N >= 16:
    N = 16
elif N >= 8:
    N = 8
elif N >= 4:
    N = 4
elif N >= 2:
    N = 2
elif N == 1:
    N = 1

print(N)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()

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

print(2**(i-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

COUNT = 1

for i in range(7):
    if N >=2**(6-i):
        COUNT = 2**(6-i)
        break

print(COUNT)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(1, n + 1):
    cnt = 0
    flag = True
    j = i
    while flag:
        if i % 2 == 0:
            i //= 2
            cnt += 1
        else:
            flag = False
    a.append([j, cnt])
print(sorted(a,key=lambda x: x[1])[-1][0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
precount = 0
if n==1:
    ans = 1
for i in range(1, n+1):
    tmp = i
    flag = 1
    count = 0
    while flag :
        flag = 0
        if i%2 == 0:
            i = i//2
            flag = 1
            count += 1
    if precount < count :
        precount = count
        ans = tmp
        
    
            

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n=int(input())
cnt=1
for i in range(0, 100):
    cnt*=2
    if cnt > n:
        print(math.floor(cnt/2))
        break

Submission status: Accepted

Solution code:
from math import *
N=int(input())
print(2**floor(log(N)/log(2)))

Submission status: Accepted

Solution code:
s=int(input())
two=[]
for i in range(8):
    two.append(2**i)
ans=0
if s in two:
    print(s)
else:
    while s>two[ans]:
        ans+=1
    print(2**(ans-1))

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:
keep=0
keeeep=1
for i in range(1,int(input())+1):
  count=0
  kept=i
  while kept%2==0:
    count+=1
    kept=kept//2
  if count>keep:
    keeeep=i
    keep=count
print(keeeep)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    nums = [0]
    for i in range(1, n + 1):
        d = i
        count = 0
        while d != 0:
            d, amari = divmod(d, 2)
            if amari != 0:
                break
            count += 1
        nums.append(count)
    if n == 1:
        print(1)
    else:
        print(nums.index(max(nums)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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