akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int P=1e9+7;
char st[300005];
int f[300005][8],ch[8][2]; //f[i][j]表示匹配到字符串中第i个字符自动机上第j个节点的方案数,ch[i][j]表示自动机上第i个节点接受j后到达的节点
void build()
{
	ch[0][0]=2; ch[0][1]=1; //0节点为空串
	ch[1][0]=3; ch[1][1]=5; //1节点为1
	ch[2][0]=4; ch[2][1]=7; //2节点为0
	ch[3][0]=6; ch[3][1]=1; //3节点为10
	ch[4][0]=2; ch[4][1]=2; //4节点为00
	ch[5][0]=5; ch[5][1]=5; //5节点为11
	ch[6][0]=3; ch[6][1]=3; //6节点为100
	ch[7][0]=2; ch[7][1]=1; //7节点为01
}
int main()
{
	build();
	scanf("%s",st+1);
	int n=strlen(st+1);
	f[n][1]=f[n][5]=1; //节点1和5是一定beautiful的
	for (int i=n-1; i>=0; i--)
		for (int j=0; j<=7; j++)
		{
			if (st[i+1]!='1') f[i][j]+=f[i+1][ch[j][0]];
			if (st[i+1]!='0') f[i][j]+=f[i+1][ch[j][1]];
			if (f[i][j]>=P) f[i][j]-=P;
		}
	printf("%d\n",f[0][0]);
	return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}


bool is_prime(ll n){
    if(n == 2) return true;
    if(n == 1 or !(n & 1)) return false;

    random_device rnd;
    ll d = (n-1) >> 1;
    while(!(d&1))
        d >>= 1;

    rep(k, 100){

        ll a = rnd() % (n-1) + 1;
        ll t = d;
        ll y = powMod(a, t, n);

        while(t != (n-1) and y != 1 and y != (n-1)){
            y = powMod(y,2,n);
            t <<= 1;
        }

        if(y != n-1 and !(t & 1)){
            return false;
        }
    }

    return true;
}



int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll h, w;
    cin >> h >> w;

    string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ans;
    rep(i, h){
        rep(j, w){
            string s;
            cin >> s;
            if( s == "snuke"){
                ans = alp[j] + to_string(i+1);
            }
        }
    }

    ppp(ans);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
string n;
  cin >> n;
  int sum = 0;
  for (int i = 0 ;i < n.size(); i++ ) {
    sum +=n[i] - '0'; }
  if (sum % 9 == 0 ) {
    cout << "Yes";}
  else {
    cout << "No";} }

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int d,t,s;
cin>>d>>t>>s;
if(s*t>=d)
cout<<"Yes";
else
cout<<"No";
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 3648
N,K=map(int,input().split());p=[int(i)-1 for i in input().split()];q=[int(i)-1 for i in input().split()]
def I(s):
 r=[0 for i in range(N)]
 for i in range(N):r[s[i]]=i
 return r
def T(s,t):
 r=[0 for i in range(N)]
 for i in range(N):r[i]=s[t[i]]
 return r
m=[[0 for i in range(N)] for i in range(6)];A=T(T(T(q,I(p)),I(q)),p);X=(K-1)//6
for i in range(N):m[0][i]=p[i];m[1][i]=q[i]
for i in range(2,6):m[i]=T(m[i-1],I(m[i-2]))
def E(s,k):
 if k==0:
  return [i for i in range(N)]
 elif k==1:
  return s
 elif k%2==0:
  return E(T(s,s),k//2)
 else:
  return T(E(T(s,s),k//2),s)
t=E(A,X);a=T(T(t,m[(K-1)%6]),I(t));print(" ".join([str(i+1) for i in a]))

Measured memory_bytes: 38728
#include <iostream>
#include <string>
#include <vector>
using namespace std;

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int getdigit(int64_t a){
    string d = to_string(a);
    return d.size();
}

int main(){
    int64_t N;
    cin >> N;
    int F = 0;
    int minf = getdigit(N);
    int a_digit,b_digit;
    vector<int64_t> div = divisor(N);
    for(int i = 1; i < div.size(); i++){
        a_digit = getdigit(div[i]);
        b_digit = getdigit(N/div[i]);
        F = (a_digit > b_digit ? a_digit : b_digit);
        if(F < minf){
            minf = F;
        }
    }
    cout << minf << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll gcd(ll a, ll b)
{
    return (b ? gcd(b, a % b) : a);
}
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n, k;
    cin >> n >> k;
    ll ans = k;
    rep(i, n - 1)
    {
        ans *= (k - 1);
    }
    c(ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
 	string s[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  	string t; cin >> t;
  	for(int i = 0; i < 7; ++i){
     	if(t == s[i]){
         	cout << 7-i << endl; 
      		return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	vector <int> a(3);
	int f=0;
	int s=0;
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	for (int i=0; i<3; i++) {
		if (a[i]==5) f++;
		else if (a[i]==7) s++;
	}
	if (f==2 && s==1) cout << "YES";
	else cout << "NO";
	return 0;
	
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
	long long N, M;
	cin >> N >> M;
	vector<pair<long long, long long>> AB(N);
	for (int i = 0; i < N; i++) {
		cin >> AB.at(i).first >> AB.at(i).second;
	}
	sort(AB.begin(), AB.end());
	long long ans = 0, p = 0;
	while (1) {
		ans += AB.at(p).first * min(AB.at(p).second, M);
		M -= AB.at(p).second;
		p++;
		if (M <= 0) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N, K;
vector<char> d;

int main() {
    cin >> N >> K;
    d.resize(K);
    for (int i = 0; i < K; i++) scanf(" %c", &d[i]);
    int flag = 1;
    while(flag) {
        string s = to_string(N);
        int tempflag = 1;
        for (int i = 0; i < s.size() && tempflag; i++) {
            for (int j = 0; j < K && tempflag; j++) {
                if (s[i] == d[j]) tempflag = 0;
            }
        }
        if (tempflag) flag = 0;
        else N++;
    }
    cout << N << endl;
}

Measured memory_bytes: 256
def main():
    A = [list(map(int,input().split())) for _ in range(3)]
    N = int(input())
    b = [int(input()) for _ in range(N)]
    bng = [[False]*3 for _ in range(3)]
    ans = "No"
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if b[i] == A[j][k]:
                    bng[j][k] = True
    if (bng[0] == [True]*3 or
        bng[1] == [True]*3 or
        bng[2] == [True]*3 or
        bng[0][0] == bng[1][0] == bng[2][0] == True or
        bng[0][1] == bng[1][1] == bng[2][1] == True or
        bng[0][2] == bng[1][2] == bng[2][2] == True or
        bng[0][0] == bng[1][1] == bng[2][2] == True or
        bng[0][2] == bng[1][1] == bng[2][0] == True):
        ans = "Yes"
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int c[N];
  for (int i = 0; i < N; i++) cin >> c[i], c[i]--;
  vector<vector<int>> graph(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int sz[N];
  fill(sz, sz + N, 1);
  long long ans[N];
  fill(ans, ans + N, (long long)N * (N + 1) / 2);
  map<int, int> mp[N];
  auto merge = [](map<int, int> &A, map<int, int> &B) {
    if (A.size() < B.size()) swap(A, B);
    for (auto &p : B) A[p.first] += p.second;
    return A;
  };
  function<void(int, int)> dfs = [&](int v, int p) {
    for (int ch : graph[v])
      if (ch != p) {
        dfs(ch, v);
        sz[v] += sz[ch];
        if (mp[v].size() < mp[ch].size()) swap(mp[v], mp[ch]);
        for (auto &p : mp[ch]) mp[v][p.first] += p.second;
      }
    mp[v][c[v]] = sz[v];
    if (p != -1) {
      long long tmp = sz[v] - mp[v][c[p]];
      ans[c[p]] -= tmp * (tmp + 1) / 2;
    }
  };
  dfs(0, -1);
  for (int i = 0; i < N; i++) {
    long long tmp = N - mp[0][i];
    ans[i] -= tmp * (tmp + 1) / 2;
  }
  for (int i = 0; i < N; i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 72816
use std::io::Read;
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut set: HashSet<usize> = HashSet::with_capacity(n);

    for _ in 0..n {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        if set.contains(&a) {
            set.remove(&a);
        } else {
            set.insert(a);
        }
    }

    return set.len().to_string();
}


Measured memory_bytes: 6396
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        Console.WriteLine((a[0] < a[1])? "0": "10");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
using namespace std;

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,inv,finv;
public:
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};


int main(){
    int N;
    cin >> N;
    mint ans = 1;
    combination c(N);
    vector<mint> beki2(N+1,1);
    for(int i=1;i<=N;i++) beki2[i] = beki2[i-1]*2;
    for(int i=0;i<N;i++) ans *= 3;
    for(int i=N/2+1;i<=N;i++) ans -= c.comb(N,i)*beki2[N-i]*2;
    cout << ans.x << endl;
}

Measured memory_bytes: 312704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin >> s;

	int i = 2;
	while (i <= s.length())
	{
		string sub_s = s.substr(0, s.length() - i);
		int half = sub_s.length() / 2;
		if (sub_s.substr(0, half) == sub_s.substr(half, half))
		{
			cout << s.length() - i << endl;
			return 0;
		}

		i += 2;
	}
}

Measured memory_bytes: 256
public func gcd( m: Int, n: Int, using gcdAlgorithm: (Int, Int) -> (Int) = gcdIterativeEuklid) -> Int {
    return gcdAlgorithm(m, n)
}

public func gcdIterativeEuklid(_ m: Int, _ n: Int) -> Int {
    var a: Int = 0
    var b: Int = max(m, n)
    var r: Int = min(m, n)
    
    while r != 0 {
        a = b
        b = r
        r = a % b
    }
    return b
}

let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

print((arr[0] * arr[1]) / gcd(arr[0], n: arr[1], using: gcdIterativeEuklid) )

Measured memory_bytes: 4208
# Aizu Problem ALDS_1_1_C: Prime Numbers
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(10000)

def is_prime(k):
    if k in primes:
        return True
    r = math.sqrt(k)
    for p in primes:
        if k % p == 0:
            return False
        if p > r:
            return True
    return True

N = int(input())
cnt = 0
for _ in range(N):
    k = int(input())
    if is_prime(k):
        cnt += 1
print(cnt)

Measured memory_bytes: 7944
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
ld distance(ll x,ll y){
  return (double)(sqrt(x*x+y*y));
}
int main(void){
  ll n;
  cin>>n;
  cout<<n*n;
  return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
if H == 1
  puts 1
elsif W == 1
  puts 1
elsif H % 2 == 0 then
  puts H * W / 2
else
  if W % 2 == 0
    puts H * W / 2
  else
    puts (H / 2 + 1) * (W / 2 + 1) + (H / 2) * (W / 2) 
  end
end


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long;
using P = pair<int, int>;

// int F, H, I, J, K, L, M, N, S, T, U;
// lint F, H, I, J, K, L, M, N, S, T, U;
string S;
// int ans;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> S;
	vector<int> count(26, 0);

	rep (i, S.length()) {
		count[S[i] - 'a']++;
	}

	rep (i, 26) {
		if (count[i] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int>
#define di             deque<int>
#define vpii           vector<pair<int,int>>
#define pi             pair<int,int>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define all(a)         a.begin(),a.end()
#define rall(a)        a.rbegin(),a.rend()
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x:a) cin>>x
#define endl           '\n'
#define ln             printf("\n");
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    string s;cin>>s;
    cout<<s.front()<<s.size()-2<<s.back();
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma") 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define ll long long
#define MP make_pair
// #define int long long
// #define MAX LONG_LONG_MAX
// #define MIN LONG_LONG_MIN
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<','<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif
using namespace std;

const size_t MAXN = 1e5 +7;


void check(){
	ll n;
	cin >> n;
	vector<ll> a(n) ,b(n);
	for(int i = 0; i < n ;i++){
		cin >> a[i];
	}
	for(int i = n-1 ;i >= 0; i--){
		cin >> b[i];
	}
	int x=0,y=n-1;
	for(int i = 0 ;i < n ;i++){
		if(a[i]==b[i]){
            if(x<n&&b[x]!=a[i]&&a[x]!=b[i]) swap(b[i],b[x++]);
            else if(0<=y&&b[y]!=a[i]&&a[y]!=b[i]) swap(b[i],b[y--]);
            else{
                cout << "No" << endl;
                return;
            }
        }
    }
    cout << "Yes" << '\n';
    for(int i = 0; i < n ;i++) cout << b[i] << " ";
}

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); 
	cin.exceptions(cin.failbit);
	int t = 1;	
	// cin >> t;
	for(int i = 1 ; i <= t ;i++){
		// cout << "Case "<< i << ":\n";
		check();
	}
	return 0;
}


Measured memory_bytes: 6356
// URL: https://atcoder.jp/contests/abc174/tasks/abc174_c

import std.algorithm, std.array, std.bitmanip, std.container, std.conv, std.format,
       std.functional, std.math, std.range, std.traits, std.typecons, std.stdio, std.string;

version(unittest) {} else
void main()
{
  int K; io.getV(K);

  if (K == 1) io.put!"{exit: true}"(1);
  if (K%2 == 0 || K%5 == 0) io.put!"{exit: true}"(-1);

  auto m = 0, s = 7;
  foreach (i; 1..K+1) {
    (m += s) %= K;
    if (m == 0) io.put!"{exit: true}"(i);
    (s *= 10) %= K;
  }
}

auto io = IO!()();
import std.stdio;
struct IO(alias IN = stdin, alias OUT = stdout)
{
  import std.meta : allSatisfy;
  import core.stdc.stdlib : exit;

  void getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }
  void getA(T)(size_t n, ref T v)
    if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }
  void getC(T...)(size_t n, ref T v)
    if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v) w = new typeof(w)(n);
    foreach (i; 0..n) foreach (ref w; v) get(w[i]);
  }
  void getM(T)(size_t r, size_t c, ref T v)
    if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }
  template getS(E...)
  {
    void getS(T)(size_t n, ref T v)
    {
      v = new T(n);
      foreach (ref w; v) foreach (e; E) mixin("get(w."~e~");");
    }
  }

  const struct PutConf
  {
    bool newline = true, flush, exit;
    string floatFormat = "%.10f", delimiter = " ";
  }

  void put(alias conf = "{}", T...)(T v)
  {
    mixin("const PutConf c = "~conf~"; putMain!c(v);");
  }
  void putB(alias conf = "{}", S, T)(bool c, S t, T f)
  {
    if (c) put!conf(t);
    else put!conf(f);
  }
  void putRaw(T...)(T v)
  {
    OUT.write(v);
    OUT.writeln;
  }

  private
  {
    dchar[] buf;
    auto sp = (new dchar[](0)).splitter;

    void nextLine()
    {
      IN.readln(buf);
      sp = buf.splitter;
    }
    void get(T)(ref T v)
    {
      if (sp.empty) nextLine();
      v = sp.front.to!T;
      sp.popFront();
    }

    void putMain(PutConf c, T...)(T v)
    {
      foreach (i, w; v) {
        putOne!c(w);
        if (i+1 < v.length) OUT.write(c.delimiter);
      }
      static if (c.newline) OUT.writeln;
      static if (c.flush) OUT.flush();
      static if (c.exit) exit(0);
    }
    void putOne(PutConf c, T)(T v)
    {
      static if (isInputRange!T && !isSomeString!T) putRange!c(v);
      else static if (isFloatingPoint!T) OUT.write(format(c.floatFormat, v));
      else static if (hasMember!(T, "fprint")) v.fprint(OUT);
      else OUT.write(v);
    }
    void putRange(PutConf c, T)(T v)
    {
      auto w = v;
      while (!w.empty) {
        putOne!c(w.front); w.popFront();
        if (!w.empty) OUT.write(c.delimiter);
      }
    }
  }
}


Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int K, A, B;
int N;
int M;
int main() {
  cin >> K >> A >> B;
  N = A / K;
  M = B / K;
  if (M - N >= 1 || A % K == 0 || B % K == 0) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 5e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 1e9+7;

int n,k;
char a[maxN]; 
int main()
{
	scanf("%s",a+1);
	int x = (a[1]-'0')*10+a[2]-'0';
	int y = (a[3]-'0')*10+a[4]-'0';
	if(x<=12 && y<=12 && x>=1 && y>=1)
	{
		puts("AMBIGUOUS"); 
	}
	else if(x<=12 && x>=1)
	{
		puts("MMYY");
	}
	else if(y<=12 && y>=1)
	{
		puts("YYMM");
	}
	else
		puts("NA");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	a+=(a==1)?13:0;b+=(b==1)?13:0;
	printf((a>b)?"Alice":((a<b)?"Bob":"Draw"));
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    rep(a, 1, N + 1) {
        if (a % 3 && a % 5) {
            ans += a;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3172
#include <iostream>

#include <string>

#include <cstddef>

using std::cin;
using std::cout;
using std::endl;

using std::string;

using std::size_t;

static string
solve(string const &s)
{
  string ret;
  for (size_t i = 0; i < s.size(); i += 2)
  {
    ret += char(s[i]);
  }
  return ret;
}

int
main()
{
  string s;
  cin >> s;
  cout << solve(s) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

int main(){
  string S,T;
  cin >> S;
  cin >> T;
  map<char, char> ms;
  map<char, char> mt;
  bool can = true;
  for(int i = 0; i < S.size(); i++){
    if(ms.count(S[i])){
      if(ms[S[i]] != T[i]) can = false;
    } else {
      ms[S[i]] = T[i];
    }
    if(mt.count(T[i])){
      if(mt[T[i]] != S[i]) can = false;
    } else {
      mt[T[i]] = S[i];
    }
  }
  cout << (can? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 776
n = int(input())
h = [int(i) for i in input().split()]

max_h = 0
for i in range(n-1):
    if max_h > h[i+1]:
        print('No')
        exit()
    if h[i] - h[i+1] >=2:
        print('No')
        exit()
    elif h[i] - h[i+1] == 1:
        h[i] -= 1
        max_h = max(max_h,h[i])
        
        
print('Yes')

Measured memory_bytes: 14224
#include <algorithm>
#include <cstdio>

static const size_t n_max = 100000;
static std::pair<char, int> A[n_max], B[n_max];

void quick_sort(size_t p, size_t q) {
  if (q - p < 2)
    return;
  size_t r = p;
  for (size_t i = p; i < q; i++)
    if (A[i].second <= A[q-1].second)
      std::swap(A[r++], A[i]);
  r--;
  quick_sort(p, r);
  quick_sort(r, q);
}

int main() {
  size_t n;
  scanf("%zu\n", &n);
  for (size_t i = 0; i < n; i++)
    scanf("%c%d\n", &A[i].first, &A[i].second);
  std::copy(A, A + n, B);
  quick_sort(0, n);
  std::stable_sort(B, B + n, [](std::pair<char, int> a, std::pair<char, int> b) { return a.second < b.second; });
  puts(std::mismatch(A, A + n, B).first == A + n ? "Stable" : "Not stable");
  for (size_t i = 0; i < n; i++)
    printf("%c %d\n", A[i].first, A[i].second);
  return 0;
}

Measured memory_bytes: 4664
m=1e9+7,P[2][3333]={1};*p,*q;c,i;f(j){q[j]=~c?*p-p[j]:p[j];j<i&&f(j+1);q[j]=(1L*q[j]+q[j+1]+m)%m;}main(){for(gets(&c);c=getchar()%3-1;f(0))p=P[i%2],q=P[++i&1];printf("%d",*q);}

Measured memory_bytes: 256
let input = require("fs").readFileSync("/dev/stdin", "utf8")

function main({ input, load, yesno, math_sum, log_json }) {
    let [N] = load()
    
    const a = N % 10
    if([2,4,5,7,9].includes(a)) return 'hon'
    if(a === 3) return 'bon'
    return 'pon'
}



// console.time()
let inputs = input.split(/[\s\n]/)
let result = main({
    input,
    yesno: value => value ? 'Yes' : 'No',
    math_sum: numbers => numbers.reduce((acc, cur) => acc + cur, 0),
    load(rows = 1, cols = 1, type = Number) {
        const length = rows * cols
        let result = inputs.splice(0, length)
        if(type !== String) result = result.map(type)
        if(cols > 1) {
            const arrays = new Array(cols)
            for(let col = 0; col < cols; col++) {
                arrays[col] = new Array()
                for(let row = 0; row < rows; row++) {
                    arrays[col].push(result[row * cols + col])
                }
            }
            result = arrays
        }
        return result
    },
    inifinite_loop_preventer() {
        throw new Error("Infinite loop")
    },
    log_json(value) {
        console.log(JSON.stringify(value))
    },
})

if(result === undefined) {
    console.warn("result is undefined")
} else {
    console.log(result)
}
// console.timeEnd()

function math_max(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n > result) result = n
    return result
}

function math_min(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n < result) result = n
    return result
}

// 素因数分解 { 素数: n乗 }
function math_prime_factors(n) {
    const result = {}

    for(let i = 2; i * i <= n; i++) {
        if(n % i === 0) {
            n /= i
            result[i] = 1
            
            while(n % i === 0) {
                n /= i
                result[i]++
            }
        }
    }

    if(n > 1) result[n] = 1

    return result
}


Measured memory_bytes: 29564
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)
  __gcd(a,b)は最大公約数を取ってくれる、aとb
  の大きい方をNとしたとき、計算量は√N
 */
const int mod = 1e9 + 7;
//ここから書き始める
int main(){
	ll n ;
	cin >> n;
	//要素数nの配列を作るテンプレート
	vector<int> A(n);
	for(int i = 0 ; i < n; i ++){
		cin>>A[i];
	}
	SORT(A);
//	for(auto x : A){
//		cout << x << " ";
//	}
//	cout <<endl;
	ll ans = 0;
	for(int i = 0 ; i < n - 2; i++){
		for(int j = i + 1 ; j < n -1 ; j++){
			ll count = 1;

			while(A[n-count] >= A[i]+A[j]&&n-count>j){
				count ++;
			}
			ll ok = (n-count) - j;
			if(n-count==j&&A[n-count+1]<A[i]+A[j]){ ok ++;}
//			che(ok,"ok");
			ans += ok ;
		}
	}
	cout << ans << endl;

}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(int argc, const char * argv[]) {
    double a, b, d, C, S, L, h;
     
    scanf("%lf %lf %lf",&a, &b, &C);
     
    C = C * M_PI / 180;
     
    h = b * sin(C);
     
    S = a * h / 2;
     
    d = sqrt(a * a + b * b - 2 * a * b * cos(C));
     
    L = a + b + d;
     
    printf("%f\n%f\n%f\n",S, L, h);
     
     
    return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <string>

int main(){
  std::string s, t;
  std::cin >> s >> t;
  int cnt = 0;
  for(int i=0; i<3; ++i)
    if(s[i] == t[i])
      ++cnt;
  std::cout << cnt << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //文字列の入力
    String AtCoder = sc.next("AtCoder");
    String s = sc.next();
    String Contest = sc.next("Contest");
    //　出力
    System.out.println(AtCoder.substring(0,1) + s.substring(0,1) + Contest.substring(0,1));
  }
}

Measured memory_bytes: 21588
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := make([]int, n)
	sum := 0
	for i := range s {
		s[i] = nextInt()
		sum += s[i]
	}
	p := sum / n
	p1 := float64(sum) / float64(n)
	if p1-float64(p) >= 0.5 {
		p++
	}
	ans := 0
	//debugf("p:%d, sum:%d, n:%d\n", p, sum, n)
	for i := range s {
		ans += (s[i] - p) * (s[i] - p)
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>

using namespace std;
 
int main(){
    int h, w, n;
    scanf("%d %d %d\n", &h, &w, &n);
    int sr, sc;
    scanf("%d %d\n", &sr, &sc);
    sr--; sc--;

    string s, t;
    getline(cin, s);
    getline(cin, t);

    int sru = sr;
    int srd = sr;
    int scl = sc;
    int scr = sc;
    for(int i = 0; i < n; ++i){
        sru -= (s.at(i) == 'U');
        srd += (s.at(i) == 'D');
        scl -= (s.at(i) == 'L');
        scr += (s.at(i) == 'R');

        if(sru < 0 || srd >= h || scl < 0 || scr >= w){
            printf("NO\n");
            return 0;
        }

        sru = min(h - 1, sru + (t.at(i) == 'D'));
        srd = max(0, srd - (t.at(i) == 'U'));
        scl = min(w - 1, scl + (t.at(i) == 'R'));
        scr = max(0, scr - (t.at(i) == 'L'));
    }

    printf("YES\n");
    return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  ll n; cin >> n;
  string s; cin >> s;

  ll black[200005] = {};
  ll white[200005] = {};

  rep(i, n) black[i+1] += black[i] + (s[i] == '#');
  rep(i, n) white[i+1] += white[i] + (s[i] == '.');

  ll ans = infll;
  rep(i, n) {
    ll left = black[i];
    ll right = white[n] - white[i+1];

    chmin(ans, left + right);
  }

  cout << ans << endl;
}

Measured memory_bytes: 6836
#include<stdio.h>

void trace(int A[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

int selectionSort(int A[], int n) {
    int min, tmp, count = 0;
    for (int i = 0; i < n; i++) {
        min = i;
        for (int j = i; j < n; j++) {
            if (A[j] < A[min]) min = j;
        }
        if (i != min) {
            tmp = A[i]; A[i] = A[min]; A[min] = tmp;
            count++;
        }
    }

    return count;
}

int main(void) {
  int A[100], i, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
      scanf("%d", &A[i]);
  }
  int count = selectionSort(A, n);
  trace(A, n);
  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;

int main(){
  string n;
  int ans = 0;

  cin >> n;

  for(int i = 0; i < 3; i++){
    if(n.at(i) == '7'){
      ans++;
    }
  }

  if(ans > 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3568
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
         static void Main(string[] args)
        {
            var s = ReadLine();
            var hashSet = new HashSet<char>();

            foreach(var c in s)
            {
                if(hashSet.Contains(c))
                {
                    WriteLine("no");
                    return;
                }
                hashSet.Add(c);
            }
            WriteLine("yes");
        }
    }
}


Measured memory_bytes: 13280
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

int main(void){
	int n=in();
	print((int)pow(2,(int)(log(n)/log(2))));
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)

typedef vector<int> vi;
typedef pair<int,int> pi;


int main()
{

    ll h;
    cin>>h;

    ll cnt=0;
    while(h>0) {
        //cout<<cnt<<endl;
        h=h/2;
        cnt++;
    }
    //cnt = log(h)/log(2);

    //cout<<cnt<<endl;
    ll res = (pow(2,cnt)-1)/(2-1);

    cout<<res<<endl;

    return 0; 
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  long long A[N];
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }

  sort(A, A+N);

  int ans=0;
  long long s=0;
  for (int i = 0; i < N-1; i++){
    s += A[i];
    if (s*2 >= A[i+1]){
      ans++;
    }else{
      ans=0;
    }
  }
  ans++;
  printf("%d\n",ans);
  
}


Measured memory_bytes: 4480
from bisect import bisect_right as br
S=input()
T=input()

def s2n(s):
    return ord(s)-97

ALF=[[] for _ in [0]*26]
for i in range(len(S)):
    ALF[s2n(S[i])].append(i)

ALF_T=[0]*26
seqT=[]
res=0
for t in T:
    i=s2n(t)
    if ALF[i]:
        if seqT:
            a=seqT[-1]
        else:
            a=-1
        j=br(ALF[i],a)
        seqT.append(ALF[i][j%len(ALF[i])])
    else:
        res=-1
if res>=0:
    tmp=[]
    m=-1
    for n in seqT:
        if m<n:
            tmp.append(n)
        else:
            res+=1
            tmp=[n]
        m=n
    res=res*len(S)+tmp[-1]+1
print(res)

Measured memory_bytes: 83660
num_list = list(input())
ops_cnt = len(num_list)-1

g= 0

for i in range(2 ** ops_cnt):
    f = ""
    op_list = [""] * ops_cnt
    for j in range(ops_cnt):
      if ((i >> j) & 1):
        op_list[ops_cnt -1 - j] = "+"

    for num,op in zip(num_list,op_list + [""]):
      f += num + op
    g += eval(f)

print(g)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[200005],b[200005],c[200005];
struct node{
	int x;int flag;
}p[200005<<1];
bool cmp(node a,node b)
{
	if(a.x ==b.x )
	return a.flag <b.flag ;
	else return a.x <b.x ;
}
int main()
{
	int n,k=0;ll sum=0;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
	scanf("%d",&a[i]);	
	b[i]=a[i]+i;c[i]=i-a[i];
	if(b[i]==c[i]) sum--;
}		
	for(int i=1;i<=n;i++)
	{
		k++;p[k].flag=0;p[k].x=b[i];
		}	
	for(int i=1;i<=n;i++)
{
	k++;p[k].flag=1,p[k].x=c[i];
	}	
	sort(p+1,p+k+1,cmp);int FLAG=0,ant1=0,ant2=0;
	p[0].x=3e9;
	for(int i=1;i<=k;++i)
	{
		if(p[i-1].x==p[i].x)
		{
			if(p[i-1].flag==0&&p[i].flag==1)
			FLAG=1;
			if(p[i].flag==0) ant1++;
			else ant2++;
			//cout<<ant1<<' '<<ant2<<endl;
		}
		else {
			if(FLAG==1) sum+=(ll)ant2*(ant1+1);
			ant1=0;ant2=0;FLAG=0;
		}
	}
	printf("%lld",sum);
 } 

Measured memory_bytes: 9260
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

#define MAX_V (ll)1e5+1

struct edge {
    ll to;
    ll cost;
};

// <最短距離, 頂点の番号>
#define P pair<ll, ll>

ll V;
vector<edge> G[MAX_V];
vector<ll> d(MAX_V, INF_LL);

void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main()
{
    cin >> V;

    vector<ll> a(V-1);
    vector<ll> b(V-1);
    vector<ll> c(V-1);

    rep(i,V-1)
    {
        cin >> a[i] >> b[i] >> c[i];
        edge e = {b[i], c[i]};
        G[a[i]].push_back(e);
        e = {a[i], c[i]};
        G[b[i]].push_back(e);
    }

    ll Q,K;
    cin >> Q >> K;

    vector<ll> x(Q);
    vector<ll> y(Q);
    rep(i,Q) cin >> x[i] >> y[i];
    
    dijkstra(K);

    rep(i,Q)
    {
        cout << d[x[i]] + d[y[i]] << endl;
    }

    /*
    rep(i,6)cout << d[i] << " ";
    cout << endl;
    */
}


Measured memory_bytes: 15088
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int H,W;
	cin >> H >> W;
	vector< vector<bool> > R(H,vector<bool>(W,false));
	vector< vector<bool> > B(H,vector<bool>(W,false));
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			if( w==W-1 || ((h&1) && w!=0) ){
				B[h][w] = true;
			}else{
				R[h][w] = true;
			}
		}
	}
	for(int h=0;h<H;++h){
		string str;
		cin >> str;
		for(int w=0;w<W;++w){
			if( str[w] != '#' ) continue;
			if( w==W-1 || ((h&1) && w!=0) ){
				R[h][w] = true;
			}else{
				B[h][w] = true;
			}
		}
	}
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			if( R[h][w] ){
				cout << '#';
			}else{
				cout << '.';
			}
		}cout << endl;
	}
	cout << endl;
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			if( B[h][w] ){
				cout << '#';
			}else{
				cout << '.';
			}
		}cout << endl;
	}
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 896
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

#define int long long

const int N = 100005;

int n, m;
int pref[N];
long long ans = 0;
multiset <int> ms;

int32_t main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ms.insert(x);
    ans += x;
  }
  vector < pair <int, int> > ve;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    ve.push_back({b, a});
  }
  sort(ve.rbegin(), ve.rend());
  bool done = 0;
  for (int i = 0; i < ve.size() && !done; i++) {
    auto here = ve[i];
    for (int j = 0; j < here.second; j++) {
      if (here.first > *ms.begin()) {
        ans -= *ms.begin();
        ms.erase(ms.begin());
        ms.insert(here.first);
        ans += here.first;
      } else {
        done = 1;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7156