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 <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;

int N;
int f(int a){
	int b = a * 2;
	if(b == N) return b;
	if(b > N) return a;
	return f(b);
}
int main() {
	cin >> N;
	if(N == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << f(1) << endl;

}

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

int main() {
	double N, i = 1.0;
	cin >> N;
	while (N >= pow(2.0, 1.0 + i)) ++i;
	cout << pow(2.0, i) << endl;
}

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

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    IN(int, n);
    int t = 1;
    while (t*2<=n) {
        t*=2;
    }
    COUT(t);
}

C++: #include<iostream>
using namespace std;
int main(){
  int x,y;
  cin>>x;
  y=1;
  while(1){
    if(x>y){
      y*=2;
    }
    else if(x==y)
      {
        cout<<y<<endl;
        break;
      }
    else{
      cout<<y/2<<endl;
      break;
    }
  }


  
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll tmp = 1;
  while ((ll)pow(2, tmp) <= n) tmp++;
  cout << (ll)pow(2, tmp-1) << endl;
}

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

int main(){
    int N;
    int result=1;
    cin>>N;

    while(true){
        if(result<N){
            result*=2;
        }else{
            break;
        }
    }

    if(result>N){
        cout<<result/2<<endl;
    }else{
        cout<<result<<endl;
    }
    
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int i = 0;
    while (pow(2, i) <= N) {
        i++;
    }
    i--;
    cout << pow(2, i) << endl;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, sum = 1; cin >> n;
	for (int h = 0; h < 30; h++) {
		sum *= 2;
		if (sum > n) {
			cout << sum / 2 << endl;
			cin >> n; return 0;
		}
	}
	cin >> n;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> pow2;
  pow2.push_back(2);
  int i;
  for (i = 0; pow2[i] <= n * 2; i++) {
    pow2.push_back(pow2[i] * 2);
  }
  i = 0;
  while (pow2[i] <= n) {
    i++;
  }
  cout << pow2[i - 1] << endl;
  return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {
	ll n;
	cin >> n;
	for (int i = 1; i < 1000; ++i) {
		if (pow(2, i) > n) {
			cout << pow(2, i) / 2 << endl;
			return 0;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(){
    int N,B=0;
    int X,A=0;
    cin >>N;
    while(B<=N){
        A++;
        X=1;
        for(int i=0;i<A;i++){
                X=X*2;
        }
        B=X;
    }
    X=1;
    for(int i=0;i<A-1;i++){
         X=X*2;
    }
    B=X;
    cout << B <<endl;
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int t = 2;
    while (t * 2 <= N) {
        t *= 2;
    }
    cout << t << "\n";
    return 0;
}

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

int func(int N){
    int sum=2;
    if(N==1) return 1;

    return sum*func(N/2);

}

int main(){
    int N; cin >> N;
    cout << func(N) << endl;
    return 0;
}