Go: package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	l, r, max := 0, 63, 0
	for l <= r {
		m := (l + r) / 2
		pow2 := 1 << uint(m)
		if pow2 <= n {
			l = m + 1
			if pow2 > max {
				max = pow2
			}
		} else {
			r = m - 1
		}
	}
	fmt.Println(max)
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>
#include <cstdio>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;

void solve(){
  cin >> n;
  int x=1;
  int p;
  while(x<=n){
    p=x;
    x*=2;
  }
  cout << p;
  cout << endl;
}

int main() {
  solve();
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int n;
  cin>>n;
  int x=2;
  for(int i=0;i<20;i++){
    if(n<x)
      break;
    else
      x*=2;
  }
  cout<<x/2<<endl;
  return 0;
  
}

C++: #include <iostream>
using namespace std;

bool isPow_of_2(int n){
    if(n==1)    return true;

    if(n%2==0)  return isPow_of_2(n/2);
    else   return false;
}

int main(){
    int n;
    cin >> n;

    if(n==1){
        cout << 1 << endl;
        return 0;
    }

    for(int i=n;i>=0;i--){
        if(isPow_of_2(i)){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

C++: #include<iostream>


using namespace std;

int main(){
    int N;
    cin >> N;
    
    int n = 1;
    while(1){
      n *= 2;
      if(n >= N) break;
    }
    if(n == N) cout << n << endl;
    else cout << n/2 << endl;
    return 0;
}

C++: #include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>

#define	rep(i, n) for(int i=0; i<n; i++)

#define P pair<int, int>

typedef long long ll;

using namespace std;

#include <string>
#include <cctype>
typedef string::const_iterator State;
class ParseError {};


int main() {
	int N, ans= 1;
	cin >> N;
	while (ans <= N)
	{
		ans *= 2;
	}
	cout << ans / 2 << endl;

	return 0;
}

C++: /*与えられた数を、それ以下の数の中で最大の2の累乗に変換してください。
   たとえば、2や3ならば2^1=2に変換してください。
   同様に4,5,6,7ならば2^2=4に、8,9,10,11,...,15ならば2^3=8に変換してください。
   与えられた数を、その数以下の数の中で最大の2の累乗に変換するプログラムを作成せよ。*/
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char const *argv[]) {
        int N, power, loop = 0;
        cin >> N;
        do {
                power = pow(2,loop);
                loop++;

        } while(power <= N/2);
        cout << power << endl;
        return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int N,ans=1;
  cin >> N;

  while(ans<=N){
    ans*=2;
  }
  ans/=2;

  cout <<ans<<endl;
  
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int N, c = 0;
    cin >> N;

    int ans = N;
    while(true){
        ans =  N / 2;
        c++;
        N = ans;
        if(N == 1){
            cout << pow(2, c) << endl;
            break;
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n;

int main() {
    cin >> n;

    llong a = 1;
    while (a <= n) {
        a *= 2;
    }
    a /= 2;

    cout << a << endl;

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;

int num = 2;
int num2;
  
  while(true){
    if(num > N){
      num = num / 2;
      break;
    }
    else if(num == N){
      break;
    }
    num = num * 2;
  }
  cout << num << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int n;
    cin >> n;
    int x = 2;
    while (x <= n) {
        x *= 2;
    }
    x/=2;
    cout << x << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main() {

  int num;
  cin>>num;

  int ans = 2;

  while(1) {
    if (ans * 2 > num) break;

    ans *= 2;
  }

  cout<<ans<<endl;

  return 0;
}

C++: #include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

void Solve(){
    UL ans = 0;
    UL a; cin >> a;
    ans = 1;
    while(ans <= a) ans *= 2;
    cout << ans / 2 << endl;
}

int main(){
    Solve();
    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;

signed main(){  
    cin >> N;
    int ans = 1;
    while(ans * 2 <= N){
        ans *= 2;
    }
    cout << ans << endl;


    return 0;
}

/*

*/

C++: #include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void) {
	int N, res=1;

	cin >> N;
	while (res * 2 <= N) res *= 2;
	cout << res << endl;

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a = 1;
    while(true){
        if (n < a * 2){
            cout << a << endl;
            break;
        }
        a *= 2;
    }
}