Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		n, _ := strconv.Atoi(line)

		var p2 = 1
		for {
			if n < 2*p2 {
				break
			}
			p2 *= 2
		}

		fmt.Printf("%v\n", p2)
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    for (int a = 1;; a <<= 1) {
        if (n < (a << 1)) {
            cout << a << "\n";
            return 0;
        }
    }
}

C++: #include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	int ans = 1;

	while (ans * 2 <= n) {
		ans *= 2;
	}
	cout << ans << endl;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ans = 1;
    while (ans << 1 <= n)
    {
        ans <<= 1;
    }
    cout << ans << "\n";
}

C++: #include <bits/stdc++.h>

using namespace std;

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

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int a;
    cin>>a;
    vector<int> g;
    for(int i=1;;++i){
        g.push_back(pow(2,i));
        if(g[i-1]>a){
            break;
        }
    }
    cout<<g[g.size()-2]<<endl;
}

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

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

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

int n, m = 2;

int main()
{
	cin >> n;

	while (m * 2 <= n)
		m *= 2;

	cout << m << endl;

	return 0;
}

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

int main(){
	vector<int> x;
	for(int i=2;i<=1000000;i*=2)x.push_back(i);

	int n;	cin>>n;
	int ans=2;
	for(int a:x){
		if(n>=a)ans=a;
	}

	cout<<ans<<endl;




	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

main(){
	int a;
	int b=1;
	int c;
	cin >> a;
	while (b <= a){
		b=b*2;
	}
	printf("%d\n",b/2);
}

C++: #include<iostream>
#include<cmath>

using namespace std;
int main()
{
    int n;
    cin >> n;
    int a=1;
    while(n>pow(2,a)){
        a++;
    }
    
    if(n==pow(2,a)){
        cout << pow(2,a) << endl;
    }else{
        cout << pow(2,a-1) << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; (1<<i) <= n; i++) {
        chmax(ans, 1<<i);
    }
    cout << ans << endl;
}

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

int main() {
    int N; cin >> N;
    int a = 1;
    while(a * 2 <= N) a *= 2;
    cout << a << '\n';
    return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

main(){
	int a;
	int b=1;
	int c;
	cin >> a;
	while (b <= a){
		b=b*2;
	}
	printf("%d\n",b/2);
}