akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<a.at(k-1);
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
#include<tuple>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<vector<long long>> table(N, vector<long long>(N));
	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
			cin >> table[i][j];

	vector<vector<long long>> edge(table);
	for(int i=0; i<N; i++)
	{
		for(int j=0; j<N; j++)
		{
			for(int k=0; k<N; k++)
			{
				edge[j][k] = min(edge[j][k], edge[j][i] + edge[i][k]);
			}
		}
	}

	for(int i=0; i<N; i++)
	{
		for(int j=0; j<N; j++)
		{
			if(edge[i][j] < table[i][j])
			{
				cout << -1 << endl;
				return 0;
			}
		}
	}

	priority_queue<tuple<int, int, int>> task;
	for(int i=0; i<N; i++)
	{
		for(int j=0; j<N; j++)
		{
			task.push(make_tuple(-table[i][j], i, j));
		}
	}

	long long ret = 0;
	while(task.empty() != true)
	{
		auto t = task.top();
		task.pop();

		int cost = -get<0>(t);
		int start = get<1>(t);
		int end = get<2>(t);

		bool flag = true;
		for(int i=0; i<N; i++)
		{
			if(i == start || i == end)
				continue;

			int c = table[start][i] + table[i][end];
			if(c == cost)
			{
				flag = false;
				break;
			}
		}

		if(flag == true)
			ret += cost;
	}

	cout << ret/2 << endl;

	return 0;
}


Measured memory_bytes: 3320
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;

void ansYes(bool flag){
    if (flag) cout << "Yes" << endl; else  cout << "No" << endl;
}

void ansYES(bool flag){
    if (flag) cout << "YES" << endl; else  cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


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

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

int nanko(string s,Int n,Int i){
    Int length = min(n - i - 1,i);
    Int ans = 0;
    for (int k = i-length;k < i;k++){
        if (s.at(k) == 'R' && s.at(i +  (i - k) == 'B')) ans++;
    }
    return ans;
}

struct datas{
    Int x;

};


int main() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl; else cout << "ABC" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<cmath>
#define bye return 0
#define speedOne ios::sync_with_stdio(false)
#define speedtwo cin.tie(0)
typedef long long int lli;
typedef long long ll;
using namespace std;
int main()
{
    speedOne;
    speedtwo;
	int a, b;
	cin >> a >>b;
	cout<<(b+a-3)/(a-1)<<"\n";
	bye;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;



int main()
{
	int highest = 0;
	int n, sum = 0;
	int high;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> high;
		if (high >= highest) {
			sum++;
			highest = high;
		}
	}


	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort()
cnt = Counter(A)

ans = 0

while A:
    a = A.pop()
    if cnt[a] <= 0:
        continue
    cnt[a] -= 1
    pair = (1 << a.bit_length()) - a
    if cnt[pair] > 0:
        ans += 1
        cnt[pair] -= 1

print(ans)


Measured memory_bytes: 33296
#include <iostream>
using namespace std;
int main () {
int a,b,c,q;int sh=0;int sh1=0;
cin>>a>>b>>c; const int B=b;int mas[B];
for(int i=0;i<b;++i)
{
    cin>>mas[i];
}
for(int i=0;i<a;++i)
{
    for (int j=0;j<b;++j)
    {   cin>>q;
        sh+=q*mas[j];
    }
if(sh+c>0) {sh1+=1;}
sh=0;
}
cout<<sh1;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define N 1010000
#define maxn 1000000000
using namespace std;
int tt;
int f[N],n,p,q;
int s[N];
int main()
{
    int n;
    scanf("%d",&n);
    int xx=303,sum=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&s[i]);
        if(s[i]%10!=0&&s[i]<xx)xx=s[i];
        sum+=s[i];
    }
    if(sum%10)cout<<sum<<endl;
    else if(xx==303)cout<<0<<endl;
    else cout<<sum-xx<<endl;
}
//a0,a1,a2,a3,a4,a5,a6
//f(a-b)
//(a-b)^(c-b)
/*
 1 2 3 4 5 0 P (p+1,p+q)  p                q
0 1 2 3 4 5 6 1 1 1 1 1 0 0 0 0 0 0 1  1 1 1 1
1 2 3 4 5 6 7 8
...
3 0
1 2
4 5
 */

Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();
    ll N;cin>>N;
    vector<ll>p(N);
    for(int i=0;i<N;i++)cin>>p[i];
    ll ans=0;
    for(int i=1;i<N-1;i++){
        vector<pair<ll,ll>>v;
        v.push_back(make_pair(p[i-1],1));
        v.push_back(make_pair(p[i],2));
        v.push_back(make_pair(p[i+1],3));
        sort(v.begin(),v.end());
        if(v[1].first==p[i])ans++;
    }
    cout<<ans<<endl;
    
    
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string w){
    vector<int> v(1000,0);
    for (auto ch : w) {
	v[ch]++;
    }

    for (int i = 0; i < v.size(); i++) {
      if (v[i] % 2 != 0) {
	  cout << NO << endl;
	  return;
      }
    }
    cout << YES << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string w;
    std::cin >> w;
    solve(w);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back

using namespace std;


ll n;
typedef pair<ll,ll> pll;
string S;
vector< ll > g[2002];
ll low[2002];
ll high[2002];
ll cnt[2002];
const ll inf = 1e16;
void dfs(ll s, ll pr)
{
        if(S[s] == '1') {
                cnt[s] = 1;
        }
        //cout << s << endl;
        vector< pll > v;
        for(auto &i : g[s]) {
                if(i == pr) continue;
                dfs(i, s);
                cnt[s] += cnt[i];
                high[s] += high[i] + cnt[i];
                v.pb(make_pair(low[i] + cnt[i], high[i] + cnt[i]));
        }
        if(v.size() == 0) return;
        sort(v.rbegin(), v.rend());
        ll ret = v[0].first;
        ll sm = v[0].first%2;
        for(ll i=1;i<v.size();i++) {
                sm += v[i].second;
                sm %= 2;
                ll ad = v[i].second;
                if(ad > v[0].first) {
                        ad = v[0].first;
                        if(ad%2 != v[i].second%2) ad--;
                }
                ret -= ad;
        }
        low[s] = max(sm , ret);

}
void solve(ll root)
{
        memset(low, 0, sizeof low);
        memset(high, 0, sizeof high);
        memset(cnt, 0, sizeof cnt);
        dfs(root, -1);
}
int main()
{
        cin >> n >> S;
        S = "$" + S;
        for(ll i=1;i<n;i++) {
                ll a,b;
                cin >> a >> b;
                g[a].pb(b);
                g[b].pb(a);
        }
        ll ans = inf;
        for(ll i=1;i<=n;i++) {
                //cout << i << " " << " .......";
                solve(i);
                if(low[i] == 0) {
                        ans = min(ans , high[i] / 2);
                }
                //cout << ans << " " << endl;
        }
        if(ans >= 1e9) ans = -1;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue>
#include <set> 
#include <stack>
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long 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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  double sum = 0;
  for(int i = 0; i <N; i++){
    sum += 1.0 / (double)A[i];
  }

  double ans = 1.0/sum;
  printf("%.10f\n", ans);

  return 0;
}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll a, b, c, ans;
    cin >> a >> b >> c;
    ans = a*a + b*b + c*c -2*a*b - 2*b*c - 2*c*a;
    // cout << ans << endl;
    if(c-a-b < 0) cout << "No" << endl;
    else if(ans <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m;
   cin >> n >> m;
   int x,sm = 0;
   f(i,0,m){
      cin >> x;
      sm += x;
   }
   if(sm<=n){
      cout << n-sm;
   }else{
      cout << "-1\n";
   }
   return 0;
} 

Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
LL n,a,b;
LL la,ans=0;
int main()
{
	scanf("%lld %lld %lld",&n,&a,&b);
	for(LL i=1;i<=n;i++)
	{
		LL c;scanf("%lld",&c);
		if(i!=1) ans+=min((c-la)*a,b);
		la=c;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
n = input()
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

if int(n[len(n)-1:]) in hon:
    print("hon")
elif int(n[len(n)-1:]) in pon:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9176
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[201][10001];
int c[200];
int d[200];
int main(){
	int a,b;
	int MOD=1000000007;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	std::sort(c,c+a);
	d[0]=c[0];
	for(int i=1;i<a;i++)d[i]=d[i-1]+c[i];
	dp[a][0]=1;
	for(int i=a;i>0;i--){
		for(int j=0;j<=b;j++){
			if(j+c[i-1]<=b)dp[i-1][j+c[i-1]]=(dp[i-1][j+c[i-1]]+dp[i][j])%MOD;
			if(j+d[i-1]>b)dp[i-1][j]=(dp[i-1][j]+dp[i][j])%MOD;
		}
	}
	int ret=0;
	for(int i=0;i<=b;i++)ret=(ret+dp[0][i])%MOD;
	printf("%d\n",ret);
}

Measured memory_bytes: 8816
#include <iostream>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

template<class T> inline bool chmax(T &a, T b) {
    if (a < b) a = b; return true;
    return false;
}

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

    ll a, b, n;
    cin >> a >> b >> n;

    ll x;
    if(n < b - 1) x = n;
    else x = b - 1;

    ll ans = floor(a * (x % b) / b);

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 100

int main() {
    int alf[26],n;
    string w;
    cin>>w;
    n=w.size();
    for(int i=0;i<26;i++){
        alf[i]=0;

    }
    for(int i=0;i<n;i++){
        alf[w[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        if(alf[i]%2==1){
        cout<<"No"<<endl;
        return 0;}
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define buli(x) (__builtin_popcountll(x))
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 1e-7
#define fcin ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;

int n, m;
int ent[111111];
int maior=0;

int main() {
	gn(n);gn(m);
	rep(i,0,m){
		gn(ent[i]);maior=max(maior,ent[i]);
	}
	int sobra=n-maior;
	printf("%d\n", max(0,maior-1-sobra));
}


















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

// 条件分岐による回答
void SwitchAns(){
    char b; cin >> b;

    switch (b)
    {
        case 'A':
            cout << 'T' << endl;
            break;
        case 'T':
            cout << 'A' << endl;
            break;
        case 'C':
            cout << 'G' << endl;
            break;
        case 'G':
            cout << 'C' << endl;
            break;
        default:
            break;
    }
}

// 連想配列による回答
void ArrayAns(){
    char b, c[128];
    c['A'] = 'T';
    c['T'] = 'A';
    c['C'] = 'G';
    c['G'] = 'C';
    cin >> b;
    cout << c[(int)b] << endl;
}

int main(){
    //SwitchAns();
    ArrayAns();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false


signed main(void){
    int N;
    int A[214514];
    cin >> N;
    REP(i,N-1){
        cin >> A[i];
    }
    
    int Ans[214514]={};
    REP(i,N-1){
        Ans[A[i]]++;
    }
    
    REP(i,N){
        cout << Ans[i+1] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 6840
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}



use std::cmp;
use std::iter::Iterator;

fn main() {
    input! {
        a:usize,
        b:usize,
        c:usize,
    }

    let mut vec = Vec::new();

    vec.push(a+b);
    vec.push(a+c);
    vec.push(b+c);


    let min = vec.iter().min().unwrap();

    println!("{}", min);

}



Measured memory_bytes: 4352
S = input()
Q = int(input())
num_rev = 0
S_front = [""] * Q
S_back = [""] * Q
 
for i in range(Q):
  inp = input()
  if len(inp) == 1:
    num_rev += 1
  else:
    T, F, C = inp.split()
    if ((num_rev % 2 == 0) and int(F) == 1) or ((num_rev % 2 == 1) and int(F) == 2):
      S_front[i] = C
    else:
      S_back[i] = C

S = "".join(S_front)[::-1] + S + "".join(S_back)
if num_rev % 2 == 0:
  print(S)
else:
  print(S[::-1])


Measured memory_bytes: 61684
#include<bits/stdc++.h>
using namespace std;
int N,K;
string t[16];
string ans="";
bool used[16];
int f[16];
int INF=1e9+7;

bool check(int key){
  vector<int> v;
  for(int i=0;i<K;i++){
    int id=t[key][i]-'A';
    v.push_back(f[id]);
  }
  for(int i=0;i+1<K;i++)
    if(v[i]>v[i+1])return false;
  return true;
}

void update(int key){
  for(int i=0;i<K;i++){
    int id=t[key][i]-'A';
    f[id]=-100-i;
  }
  vector<int> X;
  for(int i=0;i<N;i++){
    if(f[i]==INF)continue;
    X.push_back(f[i]);
  }
  sort(X.begin(),X.end());
  X.erase( unique( X.begin(),X.end() ), X.end() );
  for(int i=0;i<N;i++){
    if(f[i]==INF)continue;
    f[i]=lower_bound(X.begin(),X.end(),f[i])-X.begin();
  }
}

typedef unsigned long long ull;

ull B=1e9+9;
map< int, map< ull, bool > > mp;

bool dfs(int depth=0){
  int bit=0;
  ull key=0;
  for(int i=0;i<N;i++){
    if(used[i])bit+=(1<<i);
    key*=B;
    if(f[i]==INF) key+= 1999;
    else key+=(f[i]+1);
  }
  if(mp[bit][key])return false;
  mp[bit][key]=true;
  
  if(depth==N)return true;
  int tmp[16];
  for(int i=0;i<N;i++)tmp[i]=f[i];
  
  for(int i=0;i<N;i++){
    if(used[i])continue;
    if(!check(i))continue;
    
    update(i);
    used[i]=true;
    
    if(dfs(depth+1)){
      ans.push_back('A'+i);
      return true;
    }
    
    used[i]=false;
    for(int j=0;j<N;j++)f[j]=tmp[j];
  }
  return false;
}

int main(){
  cin>>N>>K;
  for(int i=0;i<N;i++)cin>>t[i];
  fill(used,used+N,false);
  fill(f,f+N,INF);
  dfs();
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6416
/**    epsileer 07 September 2019  23:13:28  **/    
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> PII;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TEST int t = 1; while(t--) solve()

void solve(){
    int n, sum = 0; cin>>n;
    vector<int> a(n);
    for(int i=1;i<n;i++){
        cin>>a[i];
    }
    sum += a[1];
    sum += a[n-1];
    for(int i=1;i<n-1;i++){
        sum += min(a[i], a[i+1]);
    }
    cout<<sum;
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST;
return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vvi F(N, vi(10));
    REP(i, N)
        REP(j, 10) cin >> F[i][j];
    vvl P(N, vl(11));
    REP(i, N)
        REP(j, 11) cin >> P[i][j];

    ll ans = -LINF;
    int M = 0x01 << 10;
    FOR(i,1,M) {
        int ptn = i;
        int mask = 0x01;
        vi c(N, 0);
        for(int j=0; j<10; j++) {
            if (ptn&mask) {
                for(int k=0; k<N; k++) {
                    if (F[k][j] == 1) c[k]++;
                }
            }
            mask <<= 1;
        }
        ll sum = 0;
        for(int k=0; k<N; k++) {
            sum += P[k][c[k]];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef string str;

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

void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}

void Main()
{
  str s; cin >> s;
  map<char, ll> ans;
  rep(i, s.size())
  {
    if(ans.count(s[i])) ans[s[i]]++;
    else ans[s[i]] = 1;
  }
  if(ans.size() == 2)
  {
    rep(i, s.size())
    {
      if(ans.count(s[i]))
      {
        if(ans[s[i]] != 2)
        fYn(0);
      }
    }
  }
  else
  {
    fYn(0);
  }
  fYn(1);
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

f80 dp[3000][3000];

void solve() {
  dp[0][0] = 1;
  int N;
  cin >> N;
  vf80 p(N);
  cin >> p;
  rep(i, N) rep(j, N) {
    dp[i+1][j+1] += dp[i][j] * p[i];
    dp[i+1][j] += dp[i][j] * (1-p[i]);
  }
  f80 ans = 0;
  for (int i = (N + 1) / 2; i <= N; i++) {
    ans += dp[N][i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 140928
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
void Solve() {
	int n,x;
	cin >> n >> x;
	int a[105];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	sort(a, a + n);
	int res = 0;
	for (size_t i = 0; i < n; i++)
	{

		x -= a[i];
		if (x < 0) break;
		res++;
	}
	cout << (res -(x > 0)) << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int main(){
    string S;
    cin >> S;
    bool t = false;
    if(S.length() == 3 || S.length()%2 != 0){
        t = false;
    }else{
    for(int i = 0;i<S.length()-1;i++){
        if(S.at(i)=='h'&&S.at(i+1)=='i'){
            t = true;
            i++;
        }else if((S.at(i)=='h')){
            t = false;
           
            break;
        }else{
            t = false;
        
            break;
        }
    }
    }
    if(t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 100003;

int n,a[maxn],b[maxn];
ll ans;

int read()
{
	char ch = getchar();
	int num = 0;
	bool fl = 0;
	for (; !isdigit(ch); ch=getchar())
		if (ch=='-') fl = 1;
	for (; isdigit(ch); ch=getchar())
		num = (num<<1)+(num<<3)+ch-48;
	if (fl) num = -num;
	return num;
}
int main()
{
	n = read();
	for (int i=1; i<=n; i++) a[i] = read();
	std::sort(a+1, a+n+1);
	b[1] = a[(n+1)/2];
	int l = 1, r = n, cnt = 1;
	for (int i=1, f=0; i<n; i++)
	{
		if (f) b[++cnt] = a[r--];
		else b[++cnt] = a[l++];
		f = 1-f;
	}
	ans = 0;
	for (int i=2; i<=n; i++)
		ans += abs(1ll*b[i]-b[i-1]);
	l = 1, r = n, cnt = 1;
	for (int i=1, f=1; i<n; i++)
	{
		if (f) b[++cnt] = a[r--];
		else b[++cnt] = a[l++];
		f = 1-f;
	}
	ll s = 0;
	for (int i=2; i<=n; i++)
		s += abs(1ll*b[i]-b[i-1]);
	printf("%lld\n",std::max(ans, s));
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String ans = n();
		out(ans.contains("9") ? Y : N);

	}

	/*
	 * 以下メソッド集
	 */

	public static int[] kousokusoinnsuubunkaihairetsu(int a) {
		int[] d = new int[a];
		for (int i = 0; i < a; i++) {
			d[i] = i;
		}
		for (int i = 2; i * i < a; i++) {
			for (int j = i * i; j < a; j += i) {
				if (d[j] == j)
					d[j] = i;
			}

		}

		return d;
	}

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int w;
	int d;

	XY(int h, int w, int d) {
		this.h = h;
		this.w = w;
		this.d = d;
	}
}

class NE {

	int n;
	int e;

	NE(int n, int e) {
		this.n = n;
		this.e = e;
	}
}

Measured memory_bytes: 35392
# encoding: UTF-8
success = 0
x = Array.new
y = Array.new
while line = gets do
  x += line.chomp.split
end
x.each do |t|
  y << t.to_i
end
big_n = y[0]
big_m = y[1]
big_c = y[2]
big_b = y[3..(big_m + 2)]
big_a = y[(big_m + 3)..-1]
#
# p big_n
# p big_m
# p big_c
# p big_b
# p big_a
#
i = 0
while i < big_n do
  j = 0
  sum = 0
  while j < big_m do
    sum = sum + big_a[i * big_m + j] * big_b[j]
    j = j + 1
  end
  if sum + big_c > 0 then
    success = success + 1
  end
  i = i + 1
end
puts "#{success}"

Measured memory_bytes: 1788
n1,n2,n3,n4 = map(int,input().split())
lists = [1,9,7,4]
flag = 0
if n1 in lists:
    lists.remove(n1)
    if n2 in lists:
        lists.remove(n2)
        if n3 in lists:
            lists.remove(n3)
            if n4 in lists:
                flag = 1
if flag == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
N = int(input())
ixy=[]
for i in range(N):
  x, y = map(int,input().split())
  ixy+=[[i,x,y]]
costs = [[] for i in range(N)]

ixy.sort(key=lambda x:x[1])
for j in range(N-1):
  costs[ixy[j][0]] += [(ixy[j+1][0],abs(ixy[j][1]-ixy[j+1][1]))]
  costs[ixy[j+1][0]] += [(ixy[j][0],abs(ixy[j][1]-ixy[j+1][1]))]
ixy.sort(key=lambda y:y[2])
for j in range(N-1):
  costs[ixy[j][0]] += [(ixy[j+1][0],abs(ixy[j][2]-ixy[j+1][2]))]
  costs[ixy[j+1][0]] += [(ixy[j][0],abs(ixy[j][2]-ixy[j+1][2]))]

import heapq
pq = []
heapq.heappush(pq, (0,0))

visited = [0]*N
ans = 0
while pq:
  cost, v = heapq.heappop(pq)

  if visited[v]: continue
  
  ans += cost
  visited[v]=1
  
  for u,c in costs[v]:
    if not visited[u]:
      heapq.heappush(pq, (c,u))

print(ans)

Measured memory_bytes: 83316
#include <stdio.h>

int main() {
    int a, b;

    scanf("%d %d", &a, &b);

    printf("a ");
    if (a > b) {
        printf(">");
    }
    else if (a == b) {
        printf("==");
    }
    else {
        printf("<");
    }
    printf(" b\n");

    return 0;
}

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

int main(int argc, char *argv[])
{
    int n, m;
    while (cin >> n >> m, n | m) {
        int taro[n], hana[m];
        int s, sumt = 0, sumh = 0;
        bool flag = true;
        for (int i = 0; i < n; ++i) {
            cin >> s;
            taro[i] = s;
            sumt += s;
        }
        for (int i = 0; i < m; ++i) {
            cin >> s;
            hana[i] = s;
            sumh += s;
        }
        int sub = sumt - sumh;
        for (int i = 0; i < n; ++i) {
            if (!flag)
                break;
            for (int j = 0; j < m; ++j) {
                if (!flag)
                    break;
                int tmp = (taro[i] - hana[j]) * 2;
                if (tmp == (sumt - sumh)) {
                    cout << taro[i] << ' ' << hana[j] << endl;
                    flag = false;
                }
            }
        }
        if (flag)
            cout << -1 << endl;
    }
    return 0;
}

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

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

    int before = 0;
    long long int ans = 0;
    for(int i=0;i<n;++i){
        int ti;
        cin >> ti;
        if(i == 0)continue;
        ans += min(t, ti-before);
        before = ti;
    }

    ans += t;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
	char b;
  
  	scanf("%c", &b);
  
  	if(b == 'A'){
    	printf("T\n");
    }else if(b == 'T'){
    	printf("A\n");
    }else if(b == 'C'){
    	printf("G\n");
    }else if(b == 'G'){
    	printf("C\n");
    }
  	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
ll r, D, x;

void solve() {

	cin >> r >> D >> x;

	for (int i = 1; i <= 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}

	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N;
  cin >> N;
  vector<ll> A;
  rep (i, pow(2, N)) {
    ll v0;
    cin >> v0;
    A.push_back(v0);
  }

  // dp[k]: i | j | k == k となる i, j のうち A[i] + A[j] が最大となる i, j
  vector<set<tuple<ll, ll>>> dp(pow(2, N));
  repr (k, 1, pow(2, N)) {
    dp[k] = set<tuple<ll, ll>>{make_tuple(A[0], 0), make_tuple(A[k], k)};
  }

  vector<ll> digits;
  unordered_set<ll> nums;
  ll n = 1;
  while (n < pow(2, N)) {
    digits.push_back(n);
    nums.insert(n);
    n <<= 1;
  }

  while (!nums.empty()) {
    unordered_set<ll> next_nums;
    each (k, nums) {
      dp[k] = set<tuple<ll, ll>>{*prev(dp[k].end()), *prev(dp[k].end(), 2)};
      each (d, digits) {
        if ((k | d) > k) {
          dp[k | d].insert(all(dp[k]));
          next_nums.insert(k | d);
        }
      }
    }
    nums = next_nums;
  }

  vector<ll> ans(pow(2, N), 0);
  ll m = 0;
  repr (k, 1, pow(2, N)) {
    ll a1, a2, _;
    tie(a1, _) = *prev(dp[k].end());
    tie(a2, _) = *prev(dp[k].end(), 2);
    ans[k] = m = max(m, a1 + a2);
  }

  repr (k, 1, pow(2, N)) {
    cout << ans[k] << "\n";
  }
}

Measured memory_bytes: 109552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        long[] NX=cin.ArrayLong(2,0);
        long  X=NX[1];
        int N=(int)NX[0];
        long[] x=cin.ArrayLong(N,0);
        long ans=Math.Abs(x[0]-X);
        if(N>1)
        {
          for(int i=1;i<N;i++)
          {
            long c=Math.Abs(x[i]-X);
            ans=cin2.GCDLong(ans,c);
          }
        }
        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


Measured memory_bytes: 18912
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i == 0 or i == n-1:
        ans += 0
    elif (P[i-1]<P[i] and P[i]<P[i+1]) or (P[i-1]>P[i] and P[i]>P[i+1]):
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int isPrime(int x){
    if (x < 2) return 0;
    for (int ix = 2 ; ix*ix <= x ; ix++)
        if ( x % ix == 0) return 0;
  return 1;
};

int main(){
  int N,x;
  int count = 0;
  scanf("%d",&N);
  for (int ix = 0 ; ix < N ; ix++){
    scanf("%d",&x);
    if(isPrime(x))
        ++count;
  }
  printf("%d\n",count);
  return 0;
}




Measured memory_bytes: 2108
n = gets.to_s.to_i
edges = Array.new(n-1){ gets.to_s.split.map{|t|t.to_i} }

g = Array.new(n+1){ [] }
edges.each do |u, v, c|
  g[u] << [v, c]
  g[v] << [u, c]
end

ans = Array.new(n+1){ -1 }
# used = Array.new(n+1){ false }

q = [1]
ans[1] = 0
# used[1] = true

while q.any?
  
  v = q.shift
  parent_color = ans[v]
  g[v].each do |(u, c)|
    next if ans[u] >= 0
    ans[u] = ( c.even? ? parent_color : 1 - parent_color )
    q.push u
  end
end

puts ans[1, n]

Measured memory_bytes: 28668
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] chars = s.toCharArray();
		Set<Character> set = new HashSet<>();
		for(char c: chars) {
			set.add(c);
		}
		if(set.size()%2==0) {
			if(set.contains('N')==set.contains('S')&&set.contains('E')==set.contains('W')) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int main()
{
  int i,j,n,cnt=0;
  int Gg[101][101],clr[101],d[101],pi[101],mincst,ii;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&Gg[i][j]);
    }
  }
  
  for(i=0;i<n;i++){
    clr[i]=0;
    pi[i]=-1;
    d[i]=2001;
  }
  d[0]=0;
  
  while(1){
    mincst=2001;
    for(i=0;i<n;i++){
      if(clr[i]!=2 && d[i]<mincst){
	mincst=d[i];
	ii=i;
      }
    }
    if(mincst==2001)break;
    clr[ii]=2;
    for(i=0;i<n;i++){
      if(Gg[ii][i]!=-1 && clr[i]!=2 && Gg[ii][i]<d[i]){
	pi[i]=ii;
	d[i]=Gg[ii][i];
	clr[i]=1;
      }
    }
  }
  
  for(i=0;i<n;i++){
    if(pi[i]!=-1)cnt+=Gg[i][pi[i]];
  }
  
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 1992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int h[101];

    int i, j;
    int ans;

    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &h[i]);
    }

    ans = 1;
    for(i=1;i<n;i++){
        for(j=0;j<i;j++){
            if(h[i] < h[j]){
                break;
            }
        }
        if(j == i){
            ans++;
        }
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << fixed;
    cout << a/b << " " << a%b << " " << setprecision(10) << (double)a/b << endl;

    return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
bool compare(int a, int b) {
    return a > b;
}
int main() {
    fio;
    int n;
    cin >> n;
    if (n == 0) {
        cout << "1";
    }
    else {
        cout << "0";
    }
    return 0;
}

Measured memory_bytes: 3652